Avoid passing incomplete data to perflab_render_plugin_card() and show error when plugin directory API query fails#1175
Merged
mukeshpanchal27 merged 11 commits intotrunkfrom Apr 24, 2024
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. |
Merged
westonruter
commented
Apr 23, 2024
|
|
||
| /** 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']; |
Member
Author
There was a problem hiding this comment.
I didn't see a need for the version to be mentioned among the features, so I removed it.
westonruter
commented
Apr 23, 2024
| __( '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(), |
Member
Author
There was a problem hiding this comment.
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().
westonruter
commented
Apr 23, 2024
| $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() ) ); |
Member
Author
swissspidy
reviewed
Apr 24, 2024
Co-authored-by: Pascal Birchler <[email protected]>
swissspidy
approved these changes
Apr 24, 2024
mukeshpanchal27
approved these changes
Apr 24, 2024
| 'short_description' => true, | ||
| 'icons' => true, | ||
| ), | ||
| 'fields' => array_fill_keys( $fields, true ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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_datawill 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-labelanddata-titleattributes.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