-
Notifications
You must be signed in to change notification settings - Fork 140
Fix TypeError in perflab_aao_query_autoloaded_options() by serializing non-scalar option values
#1934
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @SandiyosDev. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #1934 +/- ##
=======================================
Coverage 71.20% 71.21%
=======================================
Files 86 86
Lines 6998 7000 +2
=======================================
+ Hits 4983 4985 +2
Misses 2015 2015
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I wish to remain as an unlinked contributor for the time being, I'm only here to fix an issue I encountered. |
|
@SandiyosDev Are you using Docket Cache by any chance? This came up before: #1237. It was addressed in |
plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php
Outdated
Show resolved
Hide resolved
plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php
Outdated
Show resolved
Hide resolved
No, I switched our instance to using atec-cache-apcu from redis-cache since we're running a single instance |
…options/helper.php Co-authored-by: Weston Ruter <westonruter@google.com>
…options/helper.php Co-authored-by: Weston Ruter <westonruter@google.com>
perflab_aao_query_autoloaded_options() by serializing non-scalar option values
plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php
Outdated
Show resolved
Hide resolved
…options/helper.php Co-authored-by: Weston Ruter <westonruter@google.com>
Thanks. Technically then it seems atec-cache-apcu is not correctly implemented because it is causing |
|
One thing that would nice to add is a test case for this as was added in #1238. |
@westonruter I'd agree with adding a test case for this PR, but I'm working through the GitHub web interface and codeserver with this PHP codebase binded, and since Codeserver is running in a non-PHP context, I can't properly validate my tests. |
|
Yeah, someone can add a test if not me. |
thank you very much westonruter, you can keep the credit |
Summary
While running PHP 8.2.5, and visiting
/wp-admin/site-health.php, the following fatal error occurred in our instance:strlen(): Argument #1 ($string) must be of type string, array giventhis was triggered in
perflab_aao_query_autoloaded_options()wheneverwp_load_alloptions()returned an array or object, and the code calledstrlen()on that non-string, and since some object caching solutions can return unserialized data, it caused the fatal error above in PHP 8+Addresses #
this PR updates
perflab_aao_query_autoloaded_options()to wrap$option_valuewithmaybe_serialize()before measuring its length to make sure it’s always a valid stringRelevant technical choices
if the value is already a string, the function does nothing, if it’s an array or object, it gets validly serialized