WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 15 months ago

#39769 new defect (bug)

plugin rating: web vs backend discrepancies

Reported by: agm65 Owned by:
Milestone: WordPress.org Priority: normal
Severity: normal Version: 4.8
Component: Plugins Keywords: close
Focuses: Cc:

Description

web site wordpress.org/plugins and backend are using two different ordering directions. this may induce in error

Website https://diegobetto.com/tmp/web_rating.png

Backend https://diegobetto.com/tmp/backend_rating.png

Attachments (2)

Screen Shot 2017-02-02 at 11.01.57 AM.png (17.4 KB) - added by tristangemus 16 months ago.
Screen Shot 2017-02-02 at 11.02.01 AM.png (15.6 KB) - added by tristangemus 16 months ago.

Download all attachments as: .zip

Change History (15)

#1 @SergeyBiryukov
16 months ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 4.8

Quoting my comment from #meta2468:

Good catch, I guess the ordering in WordPress admin should be changed to follow the directory (it's the same in both current and new directory), because it's more intuitive to have 5 stars at the top.

#2 follow-up: @tristangemus
16 months ago

Welcome to core @agm65!

On my local install, they appear to be in the same order. Can anyone else reproduce this?

Can you run the three commands in terminal from your website's root directory and paste in any output?

grep -nr plugins_api_args .
grep -nr plugins_api .
grep -nr plugins_api_result .

#3 @agm65
16 months ago

Maybe is version? I'm using 4.8-alpha-40038 (not present in select box)

grep -nr plugins_api_args .
./_wp-admin/includes/plugin-install.php:17: * The first filter, {@see 'plugins_api_args'}, is for the args and gives the action
./_wp-admin/includes/plugin-install.php:18: * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that
./_wp-admin/includes/plugin-install.php:125:    $args = apply_filters( 'plugins_api_args', $args, $action );
./wp-admin/includes/plugin-install.php:17: * The first filter, {@see 'plugins_api_args'}, is for the args and gives the action
./wp-admin/includes/plugin-install.php:18: * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that
./wp-admin/includes/plugin-install.php:125:     $args = apply_filters( 'plugins_api_args', $args, $action );
grep -nr plugins_api .
./wp-content/plugins/siteorigin-panels/inc/plugin-activation.php:70:            require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // Need for plugins_api
./wp-content/plugins/wordpress-seo/vendor/yoast/license-manager/class-plugin-update-manager.php:29:                     add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
./wp-content/plugins/wordpress-seo/vendor/yoast/license-manager/class-plugin-update-manager.php:74:             public function plugins_api_filter( $data, $action = '', $args = null ) {
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:761:                                $api           = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:1493:                       $api    = $this->get_plugins_api( $slug );
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:1510:               protected function get_plugins_api( $slug ) {
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:1514:                               if ( ! function_exists( 'plugins_api' ) ) {
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:1518:                               $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
./wp-content/themes/metro-creativex/class-tgm-plugin-activation.php:1692:                       $api = $this->get_plugins_api( $slug );
./wp-content/themes/verbosa/cryout/tgmpa-class.php:758:                         $api           = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
./wp-content/themes/verbosa/cryout/tgmpa-class.php:1533:                        $api    = $this->get_plugins_api( $slug );
./wp-content/themes/verbosa/cryout/tgmpa-class.php:1550:                protected function get_plugins_api( $slug ) {
./wp-content/themes/verbosa/cryout/tgmpa-class.php:1554:                                if ( ! function_exists( 'plugins_api' ) ) {
./wp-content/themes/verbosa/cryout/tgmpa-class.php:1558:                                $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
./wp-content/themes/verbosa/cryout/tgmpa-class.php:1761:                        $api = $this->get_plugins_api( $slug );
./wp-content/themes/canape/inc/plugin-enhancements.php:344:              * plugins_api() function
./wp-content/themes/canape/inc/plugin-enhancements.php:348:             $plugin_information = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
./wp-content/themes/sapor/inc/plugin-enhancements.php:350:               * plugins_api() function
./wp-content/themes/sapor/inc/plugin-enhancements.php:354:              $plugin_information = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
./_wp-admin/includes/ajax-actions.php:3596:     $api = plugins_api( 'plugin_information', array(
./_wp-admin/includes/class-wp-plugin-install-list-table.php:208:                $api = plugins_api( 'query_plugins', $args );
./_wp-admin/includes/plugin-install.php:17: * The first filter, {@see 'plugins_api_args'}, is for the args and gives the action
./_wp-admin/includes/plugin-install.php:18: * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that
./_wp-admin/includes/plugin-install.php:21: * The second filter, {@see 'plugins_api'}, allows a plugin to override the WordPress.org
./_wp-admin/includes/plugin-install.php:26: * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the
./_wp-admin/includes/plugin-install.php:98: *         {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article}
./_wp-admin/includes/plugin-install.php:101:function plugins_api( $action, $args = array() ) {
./_wp-admin/includes/plugin-install.php:125:    $args = apply_filters( 'plugins_api_args', $args, $action );
./_wp-admin/includes/plugin-install.php:141:    $res = apply_filters( 'plugins_api', false, $action, $args );
./_wp-admin/includes/plugin-install.php:163:                    $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
./_wp-admin/includes/plugin-install.php:167:                            $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
./_wp-admin/includes/plugin-install.php:182:    return apply_filters( 'plugins_api_result', $res, $action, $args );
./_wp-admin/includes/plugin-install.php:198:    $tags = plugins_api('hot_tags', $args);
./_wp-admin/includes/plugin-install.php:435:    $api = plugins_api( 'plugin_information', array(
./_wp-admin/update.php:98:              include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
./_wp-admin/update.php:101:             $api = plugins_api( 'plugin_information', array(
./wp-admin/update.php:98:               include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
./wp-admin/update.php:101:              $api = plugins_api( 'plugin_information', array(
./wp-admin/includes/ajax-actions.php:3591:      $api = plugins_api( 'plugin_information', array(
./wp-admin/includes/class-wp-plugin-install-list-table.php:207:         $api = plugins_api( 'query_plugins', $args );
./wp-admin/includes/plugin-install.php:17: * The first filter, {@see 'plugins_api_args'}, is for the args and gives the action
./wp-admin/includes/plugin-install.php:18: * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that
./wp-admin/includes/plugin-install.php:21: * The second filter, {@see 'plugins_api'}, allows a plugin to override the WordPress.org
./wp-admin/includes/plugin-install.php:26: * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the
./wp-admin/includes/plugin-install.php:98: *         {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article}
./wp-admin/includes/plugin-install.php:101:function plugins_api( $action, $args = array() ) {
./wp-admin/includes/plugin-install.php:125:     $args = apply_filters( 'plugins_api_args', $args, $action );
./wp-admin/includes/plugin-install.php:141:     $res = apply_filters( 'plugins_api', false, $action, $args );
./wp-admin/includes/plugin-install.php:170:                     $res = new WP_Error( 'plugins_api_failed',
./wp-admin/includes/plugin-install.php:181:                             $res = new WP_Error( 'plugins_api_failed',
./wp-admin/includes/plugin-install.php:204:     return apply_filters( 'plugins_api_result', $res, $action, $args );
./wp-admin/includes/plugin-install.php:220:     $tags = plugins_api('hot_tags', $args);
./wp-admin/includes/plugin-install.php:463:     $api = plugins_api( 'plugin_information', array(
grep -nr plugins_api_result .
./_wp-admin/includes/plugin-install.php:26: * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the
./_wp-admin/includes/plugin-install.php:182:    return apply_filters( 'plugins_api_result', $res, $action, $args );
./wp-admin/includes/plugin-install.php:26: * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the
./wp-admin/includes/plugin-install.php:204:     return apply_filters( 'plugins_api_result', $res, $action, $args );

#4 @agm65
16 months ago

API rating response from http://api.wordpress.org/plugins/info/1.0/ is

s:6:"rating";d:68;s:7:"ratings";a:5:{i:1;i:11;i:2;i:3;i:3;i:0;i:4;i:3;i:5;i:17;}

So maybe can be fixed ordering rating in API code since output rendering should keep incoming order

foreach ( $api->ratings as $key => $ratecount ) {

#5 @tristangemus
16 months ago

I'l keep digging, and try the 4.8 alpha. Can you try disabling Yoast SEO?

Is this happening on just one plugin, or all of them?

Try the following if possible as well:

  1. Disable Yoast SEO, SiteOrigin Panels.
  2. Switch to a bundled Wordpress theme ie twentyseventeen

See if any of those do it.

#6 @agm65
16 months ago

Sure, but I think that I'm now banned (domain https://diegobetto.com) maybe to many tests with postman

Last edited 16 months ago by agm65 (previous) (diff)

#7 @pross
16 months ago

In my testing 4.6 and 4.7 branches are ok, latest trunk however are sorted in reverse.

Tested same plugin for all 3 branches, no plugins active.

#8 in reply to: ↑ 2 @SergeyBiryukov
16 months ago

Replying to tristangemus:

Can anyone else reproduce this?

I got the same results as @pross, looks like the API returns different results for trunk vs. direct requests (see also #meta2467).

We could fix it in core by adding krsort( $api->ratings ) before the foreach cycle.

#9 @agm65
16 months ago

My 2 cents If in the web website there is no forced order, maybe should be the same in the core and the fix should be made in the api to avoid future ordering issues

#10 @tristangemus
15 months ago

The Wordpress.org API is using the user-agent to do something on their end.

Add the following code to your theme.

Steps to show the proper order:

  1. Use the 'http_request_args' filter to modify the request args
add_filter( 'http_request_args', function( $r, $url ) {
        $r['user-agent'] = 'WordPress/4.7.2; http://wordpress.dev';

        return $r;
}, 10, 2 );
  1. Click 'View Details' on any plugin
  • You should have the proper order now.

We can of course modify the order of this on our end, but that seems messy. I haven't worked with the Wordpress.org API, I think it makes the most sense to reach out and see why there are discrepancies between WP versions as user-agents.

This ticket was mentioned in Slack in #core by tristangemus. View the logs.


15 months ago

#12 @SergeyBiryukov
15 months ago

  • Focuses ui accessibility removed
  • Keywords close added; needs-patch good-first-bug removed

WordPress trunk is currently using the new plugin directory API to test it, and I've traced the issue to the API endpoints there. #meta2468 now has a patch to address it.

#13 @dd32
15 months ago

  • Milestone changed from 4.8 to WordPress.org
  • Version changed from 4.7.2 to trunk

This should be fixed now via https://meta.trac.wordpress.org/ticket/2468 and would've only affected trunk/4.8.

Some caches may return the reverse-ordered results for the next 12-24hrs though as caches clear out slowly. I'm not against changing core too to add a specific sort here, but I'm not sure it's needed.

Note: See TracTickets for help on using tickets.