Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piwik Tracker throws SQL exceptions when using a boolean value for a tinyint(1) field #2153

Closed
julienmoumne opened this issue Mar 6, 2011 · 4 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@julienmoumne
Copy link
Member

/core/Tracker/Db/Pdo/Mysql.php#L170 with out of the box MySQL 5.5.9 throws

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'visitor_returning' at row 1

This happens because $parameters(3) is a bool variable and 'visitor_returning' is a tinyint(1) field.

One of the places this value is set is in /core/Tracker/Visit.php#L437.

Updating

'visitor_returning'         => $visitCount > 1 || $this->isVisitorKnown(),

to

'visitor_returning'         => $visitCount > 1 || $this->isVisitorKnown() ? 1 : 0,

suppresses the exception and confirms the issue.

What is the best way to go from here ?

@robocoder
Copy link
Contributor

This is a weird regression. The MySQL docs says BOOL/BOOLEAN is a synonym for TINYINT(1), and TRUE and FALSE are aliases for 1 and 0, respectively. Also, looking at Piwik's schema, visitor returning is "TINYINT(1) NOT NULL". I would have expected PHP's type conversion to yield 1 for true.

<?php  var_dump( true == 1);

Well... I'm ok with the change. I assume other TINYINT columns are affected?

@mattab
Copy link
Member

mattab commented Mar 6, 2011

+1 for patch

@julienmoumne
Copy link
Member Author

With /ticket/2154 all my integration tests are now resolved on PHP 5.3.5, MySQL 5.5.9 x64.

@julienmoumne
Copy link
Member Author

(In [4052]) fixes #2153

@julienmoumne julienmoumne added this to the Piwik 1.2.1 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants