Making WordPress.org

Changeset 10389


Ignore:
Timestamp:
10/20/2020 01:46:43 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Stats: When calculating the active usage stats, don't attempt to round to 100% if the plugin has no valid versions in use (ie. everything reported is greater than the latest stable version of the plugin).

This avoids PHP notices and invalid data for the few plugins that fit this criteria.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-internal-stats.php

    r8045 r10389  
    153153        // In these cases, we'll just alter the 'other' or final number slightly so everything adds up to 100.
    154154        // This is ultimately needed for the stats graphs to display properly.
    155         if ( array_sum( $usage ) != 100.00 ) {
     155        if ( $usage && array_sum( $usage ) != 100.00 ) {
    156156            $last_key = array_keys( $usage )[ count( $usage ) - 1 ];
    157157            $usage[ $last_key ] -= array_sum( $usage ) - 100.00;
Note: See TracChangeset for help on using the changeset viewer.