Skip to content

Harden autoloaded-options site health test for mis-implemented external object cache plugins #1238

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

Merged
merged 3 commits into from
May 23, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented May 22, 2024

Fixes #1237

In core, wp_load_alloptions() returns strings, with arrays and objects being serialized. However, some object cache plugins (namely Docket Cache) may return mixed values, including arrays and objects. This hardens perflab_aao_autoloaded_options_size() to account for this by ensuring all array and object values are serialized before computing the string length.

@westonruter westonruter added this to the performance-lab 3.2.0 milestone May 22, 2024
@westonruter westonruter added the [Type] Bug An existing feature is broken label May 22, 2024
@westonruter westonruter marked this pull request as ready for review May 22, 2024 17:12
Copy link

github-actions bot commented May 22, 2024

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @bobbyferran.

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.

Unlinked contributors: bobbyferran.

Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter force-pushed the harden/perflab_aao_autoloaded_options_size branch from 816ba26 to eef3e5b Compare May 22, 2024 20:24
@bobbyferran
Copy link

bobbyferran commented May 22, 2024

This was the error path:

Error Details
=============
An error of type E_ERROR was caused in line 106 of the file /home3/flowergu/public_html/wp-content/plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php. Error message: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, array given in /home3/flowergu/public_html/wp-content/plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php:106
Stack trace:
#0 /home3/flowergu/public_html/wp-content/plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php(22): perflab_aao_autoloaded_options_size()
#1 /home3/flowergu/public_html/wp-admin/includes/class-wp-site-health.php(194): perflab_aao_autoloaded_options_test()
#2 /home3/flowergu/public_html/wp-admin/includes/class-wp-site-health.php(145): WP_Site_Health->perform_test('perflab_aao_aut...')
#3 /home3/flowergu/public_html/wp-includes/class-wp-hook.php(324): WP_Site_Health->enqueue_scripts('site-health.php')
#4 /home3/flowergu/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#5 /home3/flowergu/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#6 /home3/flowergu/public_html/wp-admin/admin-header.php(118): do_action('admin_enqueue_s...', 'site-health.php')
#7 /home3/flowergu/public_html/wp-admin/site-health.php(96): require_once('/home3/flowergu...')
#8 {main}
thrown

@bobbyferran
Copy link

Ok, trying to figure out how to link the accounts. This is my wordpress.org account too, they should be linked.

@westonruter
Copy link
Member Author

@mukeshpanchal27 mukeshpanchal27 merged commit b2a0c6e into trunk May 23, 2024
14 checks passed
@mukeshpanchal27 mukeshpanchal27 deleted the harden/perflab_aao_autoloaded_options_size branch May 23, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance Lab Led to a Critical Error with Site Health
3 participants