From c38702d972f1c178fa042a93fa12fb0235fef8f6 Mon Sep 17 00:00:00 2001 From: Mormegil Date: Sat, 20 Sep 2014 23:20:56 +0000 Subject: [PATCH] Fix special case at Special:MediaStatistics When a percentage was equal to 100 %, makePercentPretty determined it should have zero decimal places, and the resulting string "100" had "trailing 0's" removed, resulting in a completely wrong "1". We might either check if the number contains the decimal dot prior to trimming, or spare the hassle for the special case completely. Change-Id: I15ac5caa275d72909adba27b6b88824a830bd574 --- includes/specials/SpecialMediaStatistics.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/specials/SpecialMediaStatistics.php b/includes/specials/SpecialMediaStatistics.php index 681c332f86..3fd84138e1 100644 --- a/includes/specials/SpecialMediaStatistics.php +++ b/includes/specials/SpecialMediaStatistics.php @@ -185,6 +185,9 @@ class MediaStatisticsPage extends QueryPage { if ( $decimal == 0 ) { return '0'; } + if ( $decimal >= 100 ) { + return '100'; + } $percent = sprintf( "%." . max( 0, 2 - floor( log10( $decimal ) ) ) . "f", $decimal ); // Then remove any trailing 0's return preg_replace( '/\.?0*$/', '', $percent ); -- 2.20.1