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

Add "Audit Autoloaded Options" Site Health Check #6622

Conversation

mukeshpanchal27
Copy link
Member

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.

@mukeshpanchal27 mukeshpanchal27 marked this pull request as ready for review May 24, 2024 11:42
Copy link

github-actions bot commented May 24, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mukesh27, joemcgill, rajinsharwar, costdev, audrasjb.

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

@mukeshpanchal27 mukeshpanchal27 requested a review from joemcgill May 24, 2024 11:42
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

@joemcgill joemcgill left a 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.

image

Without the filter, this is what I see:

image

src/wp-admin/includes/class-wp-site-health.php Outdated Show resolved Hide resolved
src/wp-admin/includes/class-wp-site-health.php Outdated Show resolved Hide resolved
src/wp-admin/includes/class-wp-site-health.php Outdated Show resolved Hide resolved
tests/phpunit/tests/admin/wpSiteHealth.php Show resolved Hide resolved
@mukeshpanchal27
Copy link
Member Author

It seems like Tests with GB src and build is failing ❌

Cannot access this declaration file. You may need to run tsc again: /home/runner/work/wordpress-develop/wordpress-develop/src/wp-content/plugins/gutenberg/packages/core-data/build-types/index.d.ts

@mukeshpanchal27 mukeshpanchal27 requested review from Rajinsharwar, joemcgill and adamsilverstein and removed request for Rajinsharwar May 27, 2024 05:37
Copy link
Member

@joemcgill joemcgill left a 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.

@mukeshpanchal27 mukeshpanchal27 requested a review from joemcgill June 3, 2024 08:24
Copy link
Contributor

@costdev costdev left a 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.

@mukeshpanchal27
Copy link
Member Author

Thanks, @costdev, for the feedback.

@joemcgill, I have updated the copy content.

@mukeshpanchal27 mukeshpanchal27 requested a review from costdev June 3, 2024 17:34
Copy link
Contributor

@audrasjb audrasjb left a 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>',
Copy link
Contributor

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>',
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @joemcgill

Copy link
Member

@joemcgill joemcgill left a 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>',
Copy link
Member

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.

Copy link
Contributor

@costdev costdev left a 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!

@joemcgill
Copy link
Member

Merged in https://core.trac.wordpress.org/changeset/58332.

@joemcgill joemcgill closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done 😃
Development

Successfully merging this pull request may close these issues.

5 participants