-
Notifications
You must be signed in to change notification settings - Fork 101
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
Avoid passing incomplete data to perflab_render_plugin_card() and show error when plugin directory API query fails #1175
Avoid passing incomplete data to perflab_render_plugin_card() and show error when plugin directory API query fails #1175
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 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. |
|
||
/** This filter is documented in wp-admin/includes/class-wp-plugin-install-list-table.php */ | ||
$description = apply_filters( 'plugin_install_description', $description, $plugin_data ); | ||
$version = $plugin_data['version']; |
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 didn't see a need for the version to be mentioned among the features, so I removed it.
wp_die( | ||
wp_kses( | ||
sprintf( | ||
/* translators: %s: Support forums URL. */ | ||
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'default' ), | ||
__( 'https://wordpress.org/support/forums/', 'default' ) | ||
), | ||
) . ' ' . $api->get_error_message(), |
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.
Now the specific error is shown rather than just the generic message.
The error message may include markup such as is returned by validate_plugin_requirements().
@@ -304,7 +304,7 @@ function perflab_install_activate_plugin_callback() { | |||
|
|||
$result = activate_plugin( $plugin_basename ); | |||
if ( is_wp_error( $result ) ) { | |||
wp_die( esc_html( $result->get_error_message() ) ); | |||
wp_die( wp_kses_post( $result->get_error_message() ) ); |
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.
Co-authored-by: Pascal Birchler <pascalb@google.com>
'short_description' => true, | ||
'icons' => true, | ||
), | ||
'fields' => array_fill_keys( $fields, true ), |
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.
Nice ❤️
Summary
When working on Image Prioritizer (#1172), I added the plugin to the
perflab_get_standalone_plugin_data()
but then I started getting PHPUnit test failures. I also got a bunch of warnings on the Performance screen:The issue here is that Image Prioritizer is not on WordPress.org yet, so the call to
perflab_query_plugin_info()
is returning an empty array. Nevertheless, this logic inperflab_render_plugin_card()
is not working as expected:performance/includes/admin/plugins.php
Lines 130 to 134 in cb5a37e
This is because we are merging the response from WordPress.org with our own data from
perflab_get_standalone_plugin_data()
meaning$plugin_data
will never be empty:performance/includes/admin/plugins.php
Lines 76 to 88 in cb5a37e
This scenario could happen not only if the plugin is not on WordPress.org but also if the query fails due to WordPress.org being down. So with this PR an error is now shown when an error occurs:
This PR also removes the standalone plugin version from being referenced on the Performance screen. It was only referenced in
aria-label
anddata-title
attributes.Lastly, when a WordPress.org Plugins API query fails during installation, an error message is now displayed rather than just a generic error.
Related: #1170