Making WordPress.org

Opened 14 months ago

Last modified 3 weeks ago

#2606 assigned defect

Inaccurate plugin rating counts

Reported by: svenl77 Owned by: Otto42
Milestone: Plugin Directory v3.0 Priority: normal
Component: Plugin Directory Keywords: needs-patch


I found a wired behave in the new plugin directory. Deleted spam reviews still get counted

Example: https://wordpress.org/plugins/bp-wc-vendors/ the two 1 star have been deleted but still get count

Change History (12)

#1 @netweb
14 months ago

  • Keywords needs-patch added
  • Summary changed from Deleted spam reviews still get counted to Inaccurate plugin rating counts

Welcome to Trac and thanks for the ticket @svenl77

To clarify things a little further, currently there are two 5 star reviews, and three 1 star reviews that have been "archived". The plugin page shows two 5 star reviews and two 1 star reviews, it should show only the two published 5 star ratings, the same as the reviews page.

This is also only an issue on the plugin page: https://wordpress.org/plugins/bp-wc-vendors/

  • https://cldup.com/TGqDzKEcVe.png

The plugin correctly only shows only the two 5 star reviews on the review page: https://wordpress.org/support/plugin/bp-wc-vendors/reviews/

  • https://cldup.com/O0x6B4bm_s.png

#2 follow-up: @Otto42
14 months ago

  • Owner set to Otto42
  • Status changed from new to assigned

This is because the get_star_rating function is using the post_meta, when it should be calling the existing and centralized ratings code to get the information correctly. Said ratings code also contains the necessaries to create the HTML for the bars, so some simple de-duplication of code should fix this.

This ticket was mentioned in Slack in #meta by ipstenu. View the logs.

14 months ago

#4 @keraweb
13 months ago

What is the status for this issue? I have the same thing with one of my plugins. The WP.org API returns the archived/spammed reviews as well.

This ticket was mentioned in Slack in #meta by dd32. View the logs.

13 months ago

#6 in reply to: ↑ 2 @SergeyBiryukov
7 months ago

Replying to Otto42:

This is because the get_star_rating function is using the post_meta, when it should be calling the existing and centralized ratings code to get the information correctly.

It used to call WPORG_Ratings methods via Plugin_Directory::filter_shim_postmeta() before [4420], but apparently post meta fields are necessary for search indexing.

Looking at Meta_Sync::sync_ratings(), the post meta is supposed to be synchronized with WPORG_Ratings data hourly, so the information should eventually be correct, even though there is some delay.

To reduce confusion and avoid discrepancy between the ratings on support forums and on plugin page, we could probably trigger a sync right after a review is archived or marked as spam.

#7 @SergeyBiryukov
7 months ago

On second thought, switching Template::get_star_rating() back to using WPORG_Ratings methods might indeed be easier. WPORG_Ratings is not open-sourced yet, so I'm not sure which way is better in terms of performance, but the same methods are used on support forums, so it would at least bring parity.

#8 @dd32
7 weeks ago

  • Priority changed from normal to low

Just noting that it looks like some plugins post_meta got out of sync, due to the cron only picking up recently added reviews. Removing a review doesn't trigger any syncing and that causes it to ultimately be out of date.

When a spam review is removed, the next review added after that will trigger the resync. Because the action of adding a new review clears out the bad data, this makes this even more low-priority in my eyes.

Fixing this by using the underlying WPORG_Ratings class rather than post meta would probably make sense.
As a temporary work around I just ran a script to resync all the rating counts (commit following)

#9 @dd32
7 weeks ago

In 7029:

Plugin Directory: Ratings/Reviews: Add a bin script to resync the underlying ratings data to plugin post_meta
Sometimes the post_meta gets out of sync with the ratings system data due to spam reviews being removed (which don't trigger a sync) and no new reviews being added to the plugin for a while. During that time the plugin will have the previous review count, and only adding a new review will clear that cache.

See #2606.

#10 @dd32
7 weeks ago

In 7030:

Plugin Directory: Ratings/Reviews: Enhance the bin script from r7029 to also operate on a singular plugin.

See #2606.

#11 @dd32
7 weeks ago

  • Priority changed from low to normal

As I hit enter on the commit, I realised that this is a little more of an issue for plugins who have a bunch of spam 5-star reviews removed. As such I added a parameter to allow devs to sync a singular plugins ratings too

Because of 5-star spam reviews, fixing this is a little more important.

This ticket was mentioned in Slack in #meta by tellyworth. View the logs.

3 weeks ago

Note: See TracTickets for help on using tickets.