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

WARNING: core/Settings/Storage/Storage.php(86): Notice - Array to string conversion #15234

Closed
tsteur opened this issue Dec 4, 2019 · 3 comments · Fixed by #15249 or #15327
Closed

WARNING: core/Settings/Storage/Storage.php(86): Notice - Array to string conversion #15234

tsteur opened this issue Dec 4, 2019 · 3 comments · Fixed by #15249 or #15327
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Dec 4, 2019

image

Noticed this in the plugin settings table. Basically there is an array stored but we expect a string or integer. Not sure how this happens as I think it does set only a string in the application. Maybe some race condition?

This breaks the archiving for us.

Looking only quickly at the code I don't really understand how this could happen: https://github.com/matomo-org/matomo/blob/3.13.0/plugins/Tour/Engagement/Challenge.php#L142-L148

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Dec 4, 2019
@tsteur tsteur added this to the 3.13.1 milestone Dec 4, 2019
@tsteur
Copy link
Member Author

tsteur commented Dec 4, 2019

I have an idea how this happens...

basically, at the same time two processes are inserting the same data:
https://github.com/matomo-org/matomo/blob/3.13.0/core/Settings/Storage/Backend/PluginSettingsTable.php#L96-L98

Then because the same key exists twice, it turns it into an array here: https://github.com/matomo-org/matomo/blob/3.13.0/core/Settings/Storage/Backend/PluginSettingsTable.php#L135-L139

And next time the value gets saved it will be stored as the array again...

@tsteur
Copy link
Member Author

tsteur commented Dec 4, 2019

Wonder if we want to use locks to avoid this issue in general around this code: https://github.com/matomo-org/matomo/blob/3.13.0/core/Settings/Storage/Backend/PluginSettingsTable.php#L78-L101

Otherwise could do transactions I suppose but maybe not every DB supports it.

We could also execute all inserts at once (bulk insert) but this wouldn't fully avoid the issue as basically there is still a gap between delete an insert.

Another possibility would be here to iterate over all settings, and converted any array to the related value if the key has the skipped or completed appendix: https://github.com/matomo-org/matomo/blob/3.13.0/plugins/Tour/Engagement/Challenge.php#L86

Most of the plugin settings usually would not have concurrency issues but this tour plugin settings is a bit different. So we could potentially avoid most of the issues by making sure we convert any array to a string for these keys.

There might be also more options using other locks that we have etc. Not sure which one is best. Fixing the plugin settings class be certainly best.

@katebutler katebutler self-assigned this Dec 4, 2019
@tsteur
Copy link
Member Author

tsteur commented Dec 5, 2019

image

just noticed the same issue with bingsiteurl... not sure this is also some race condition or maybe a different issue @sgiehl ?

googlevideokeywords was defined twice as well
image

@mattab mattab changed the title WARNING: ccore/Settings/Storage/Storage.php(86): Notice - Array to string conversion WARNING: core/Settings/Storage/Storage.php(86): Notice - Array to string conversion Jan 16, 2020
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
2 participants