-
Notifications
You must be signed in to change notification settings - Fork 107
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
Fix WordPress.DB.DirectDatabaseQuery.DirectQuery
warning for Autoloaded Options Health Check
#1179
Conversation
Ref issue: 919 WordPress#919
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 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. |
WordPress.DB.DirectDatabaseQuery.DirectQuery
warning for Autoloaded Options Health Check
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
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 working on this @Ellusu! Left a couple questions/suggestions.
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, @Ellusu. Looks good to me.
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 tried resolving conflicts to this branch following some of the upstream PHPStan changes were applied, and looks like it's caught that the return value is slightly changed following this change. Would be good to review and see if the docblock just needs to be updated, or if something in the function needs to be updated.
Ah, my bad. I got the typing wrong here: https://github.com/WordPress/performance/pull/1188/files#r1591653385 Fixed in 6f89a54. |
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 update.
Left some nit-pick. Can we update test_perflab_aao_autoloaded_options_size
tests to remove the query?
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.
Looks good to me.
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.
LGTM. Let's merge once @mukeshpanchal27 approves.
'autoload' => 'true', | ||
), | ||
admin_url( 'site-health.php' ) | ||
) | ||
); | ||
$disable_button = sprintf( '<a class="button" href="%s">%s</a>', esc_url( $url ), esc_html__( 'Revert to Autoload', 'performance-lab' ) ); | ||
$html_table .= sprintf( '<tr><td>%s</td><td>%s</td><td>%s</td></tr>', esc_html( $value->option_name ), size_format( $value->option_value_length, 2 ), $disable_button ); | ||
$html_table .= sprintf( '<tr><td>%s</td><td>%s</td><td>%s</td></tr>', esc_html( $option_name ), size_format( $option_length, 2 ), $disable_button ); |
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.
With the PHPStan level updates, this line was now giving an error about $option_name
potentially not being a string. In normal plugin operation this would always be a string. But since any other plugin can manipulate options as well, there's no guarantee that it will be an array of strings. So I've added these checks in 3dd2f69.
if ( count( $disabled_options_summary ) === 0 ) { | ||
return ''; | ||
} |
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 realized that with the refactor here, it is possible for $disabled_options_summary
to be an empty array at this point, if none of the options are in the database anymore. This is quite unlikely, but to account for this I've added e6f8650.
Fixes #919
Summary
Fix to reduce direct database call as suggested by Plugin Check
OLD:
NEW: