-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add "Audit Autoloaded Options" Site Health Check #6622
Add "Audit Autoloaded Options" Site Health Check #6622
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me. Left a few bits of feedback inline.
To test, I added this code to an mu-plugin to filter the size limit to 0, to ensure the check got triggered:
add_filter( 'wp_autoloaded_options_limit_size_in_bytes', '__return_zero' );
And I can see the following issue.
Without the filter, this is what I see:
It seems like Tests with GB src and build is failing ❌
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick about documenting arrays in return values, but this is looking close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mukeshpanchal27!
I dropped a few changes for consistency in Core and the test suite. None are blockers and can be addressed post-commit, though all are small changes and could be included pre-commit.
Co-authored-by: Colin Stewart <[email protected]>
Thanks, @costdev, for the feedback. @joemcgill, I have updated the copy content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left two comment about string internationalization
), | ||
'description' => sprintf( | ||
/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */ | ||
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.' ) . '</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rather use _n()
to take into account singular autoloaded option?
$result['label'] = __( 'Autoloaded options could affect performance' ); | ||
$result['description'] = sprintf( | ||
/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */ | ||
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can review the options being autoloaded in your database and remove any options that are no longer needed by your site.' ) . '</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rather use _n()
to take into account singular autoloaded option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core itself loads multiple autoloaded options during site setup, so I think it would be fairly edge case to have a site containing only one autoloaded option. Probably not worth the complication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @joemcgill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the copy of the description for when the check fails. I think this is good to commit and we can continue to wordsmith if needed during beta.
$result['label'] = __( 'Autoloaded options could affect performance' ); | ||
$result['description'] = sprintf( | ||
/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */ | ||
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can review the options being autoloaded in your database and remove any options that are no longer needed by your site.' ) . '</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core itself loads multiple autoloaded options during site setup, so I think it would be fairly edge case to have a site containing only one autoloaded option. Probably not worth the complication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates Mukesh!
Co-authored-by: Colin Stewart <[email protected]>
Trac ticket: https://core.trac.wordpress.org/ticket/61276
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.