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.94k stars 2.66k forks source link

Warning - Array to string conversion in Pdo.php(229) from DataAccess/Model.php #21410

Open tsteur opened 1 year ago

tsteur commented 1 year ago

Saw below warning in Matomo 5 in our logs. Unsure if this is new to Matomo 5 or has happened before in Matomo 4.

Looking at core/DataAccess/Model.php(914) maybe there's an issue when eg $idSite is an array or so?

Unfortunately, I don't have more information

WARNING CoreAdminHome[2023-10-02 21:21:08 UTC] [d2480 /libs/Zend/Db/Statement/Pdo.php(229): Warning - Array to string conversion - Matomo 5.0.0-rc4 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) [internal function]: Piwik\ErrorHandler::errorHandler(),#1/libs/Zend/Db/Statement/Pdo.php(229),#2/libs/Zend/Db/Statement.php(300),#3/libs/Zend/Db/Adapter/Abstract.php(479),#4/libs/Zend/Db/Adapter/Pdo/Abstract.php(238),#5/core/Db/Adapter/Pdo/Mysql.php(325),#6/libs/Zend/Db/Adapter/Abstract.php(827),#7/core/Db.php(344),#8/core/DataAccess/Model.php(914),#9/core/ArchiveProcessor/Loader.php(530)

bx80 commented 1 year ago

I tried to recreate this by creating invalidations with multiple sites, but they were correctly parsed into multiple invalidations. As a workaround we could add a check to ensure that parameters are of the correct type and log the parameters for further debugging if not.

MatomoForumNotifications commented 12 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/error-when-creating-a-new-segment/54274/2

KimCarolyn2023 commented 12 months ago

Hi @bx80 does this bug affect the functionality of the segment? Can the data still be trusted? Thanks in advance.

bx80 commented 12 months ago

Hi @KimCarolyn2023, it looks like the code that throws the error is checking whether an archive invalidation exists, so it seems unlikely that it would cause the segment data to be inaccurate, but it could potentially prevent a segment being updated - unfortunately it's hard to tell without more investigation.

If you have any additional information on recreating this issue then that could be useful :+1:

lneuville commented 10 months ago

Hi, I'm having the same issue as @KimCarolyn2023 when creating a simple segment on a Matomo Cloud site (Acquisition Channel = search).

WARNING: /libs/Zend/Db/Statement/Pdo.php(229): Warning - Array to string conversion - Matomo 5.0.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: API, Action: get, Method: API.get, In CLI mode: false)

Don't know what to do here

Thanks for any idea

Good'day

bx80 commented 10 months ago

Thanks for the extra details @lneuville. From what I can see from where the error occurs, as long as the segment was created and has data then you shouldn't need to do anything.

We'll need to schedule time to investigate this issue in more depth and work out what particular circumstances cause the error.

sgiehl commented 10 months ago

I had a quick look. I don't think that's caused by the idSites. It's more likely caused by the reports parameter. The problem might have its origin here: https://github.com/matomo-org/matomo/blob/adcae6d34f7fd5cfb23036924193692261386baa/core/Archive.php#L910-L924

The report parameter might be set to $archiveNames, which can be an array. This will be set to the archive parameters as archiveOnlyReport. And the archive loader might then pass it to hasInvalidationForPeriodAndName here: https://github.com/matomo-org/matomo/blob/8878b7a5872bfb52a22124f529fcd7de7270f370/core/ArchiveProcessor/Loader.php#L530

But hasInvalidationForPeriodAndName uses this parameter as string only.

Haven't tested in which constellation this might happen, but might help when trying to reproduce.

9joshua commented 9 months ago

Another Cloud customer reported this: WARNING: /libs/Zend/Db/Statement/Pdo.php(229): Warning - Array to string conversion - Matomo 5.0.2 Error received when modifying a segment.

MatomoForumNotifications commented 8 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/warning-libs-zend-db-statement-pdo-php-229/55710/2

MatomoForumNotifications commented 8 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/warning-libs-zend-db-statement-pdo-php-229-warning-array-to-string-conversion-matomo-5-0-0-rc9/54747/3

9joshua commented 7 months ago

Another Cloud customer reported this: WARNING: /libs/Zend/Db/Statement/Pdo.php(229): Warning - Array to string conversion Error received when creating a new segment with a simple filter (Channel Type = search).

9joshua commented 7 months ago

Another Cloud customer is seeing this error quite regularly, especially when using longer time periods and/or segments. image

MatomoForumNotifications commented 1 month ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/warning-array-to-string-conversion-matomo-5-2-0/60881/2

paul-buttimore commented 4 days ago

Another Cloud customer reported this today: WARNING: /libs/Zend/Db/Statement/Pdo.php(229): Warning - Array to string conversion