matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.92k stars 2.66k forks source link

[Bug] SQL insert error for the table "user_token_auth" repeatedly printed in the PHP logs #22724

Closed hajamohamedm closed 3 weeks ago

hajamohamedm commented 3 weeks ago

What happened?

I see a particular matomo error repeatedly printed in the PHP logs. The error log indicates a mismatch of datatype being inserted into DB from what is already configured in the schema.

[29-Oct-2024 14:02:46 UTC] [172.19.254.7] Error in Matomo (tracker): Error query: Error query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column analytics.matomo_user_token_auth.secure_only at row 1 In query: INSERT INTO matomo_user_token_auth (login, description, password, date_created, date_expired, system_token, hash_algo, secure_only) VALUES (?, ?, ?, ?, ?, ?, ?, ?) Parameters: array ( 0 => 'matomo_admin', 1 => 'System generated CliMultiNonAsyncArchive', 2 => '993a80dd00cc4b7794e4b186cfab2f24566abeff81a89525dc99315d96a71d96fc256b6b7b587a86a7944605577b4dbaa3c2d126853a0370450d489e0a6ff881', 3 => '2024-10-29 14:02:46', 4 => '2024-10-31 02:02:46', 5 => 1, 6 => 'sha512', 7 => false, )

The "secure_only" column's datatype of the table "matomo_user_token_auth" should be changed to match with boolean, or else in code all inserts/updates to this column should follow TINYINT as described in the schema.

What should happen?

There should not be any SQL insert errors printed in the PHP logs due to incorrect datatype.

How can this be reproduced?

Do a fresh installation of Matomo 5.1.1 and then complete all the steps of the configuration until the Matomo dashboard is ready to use. This particular error will continue to print in logs within a day of using the Matomo dashboard.

Matomo version

5.1.1

PHP version

8.1.28

Server operating system

Windows Server 2022

What browsers are you seeing the problem on?

Firefox

Computer operating system

Windows 10

Relevant log output

[29-Oct-2024 14:02:46 UTC] [172.19.254.7] Error in Matomo (tracker): Error query: Error query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `analytics`.`matomo_user_token_auth`.`secure_only` at row 1 In query: INSERT INTO matomo_user_token_auth (login, description, password, date_created, date_expired, system_token, hash_algo, secure_only) VALUES (?, ?, ?, ?, ?, ?, ?, ?) Parameters: array (   0 => 'matomo_admin',   1 => 'System generated CliMultiNonAsyncArchive',   2 => '993a80dd00cc4b7794e4b186cfab2f24566abeff81a89525dc99315d96a71d96fc256b6b7b587a86a7944605577b4dbaa3c2d126853a0370450d489e0a6ff881',   3 => '2024-10-29 14:02:46',   4 => '2024-10-31 02:02:46',   5 => 1,   6 => 'sha512',   7 => false, )

Validations

sgiehl commented 3 weeks ago

Hey @hajamohamedm

Thanks for creating this issue. This had not yet been reported before, so it could likely also be depending to OS or MySQL version. I've quickly checked the code, and we indeed pass a boolean, while an integer is expected. I'll create a PR to fix this.