summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialMediaStatistics.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialMediaStatistics.php')
-rw-r--r--includes/specials/SpecialMediaStatistics.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/includes/specials/SpecialMediaStatistics.php b/includes/specials/SpecialMediaStatistics.php
index 681c332f..b62de5d2 100644
--- a/includes/specials/SpecialMediaStatistics.php
+++ b/includes/specials/SpecialMediaStatistics.php
@@ -73,6 +73,10 @@ class MediaStatisticsPage extends QueryPage {
'namespace' => NS_MEDIA, /* needs to be something */
'value' => '1'
),
+ 'conds' => array(
+ // WMF has a random null row in the db
+ 'img_media_type IS NOT NULL'
+ ),
'options' => array(
'GROUP BY' => array(
'img_media_type',
@@ -99,7 +103,7 @@ class MediaStatisticsPage extends QueryPage {
*
* @param $out OutputPage
* @param $skin Skin (deprecated presumably)
- * @param $dbr DatabaseBase
+ * @param $dbr IDatabase
* @param $res ResultWrapper Results from query
* @param $num integer Number of results
* @param $offset integer Paging offset (Should always be 0 in our case)
@@ -153,7 +157,8 @@ class MediaStatisticsPage extends QueryPage {
);
$row .= Html::rawElement(
'td',
- array(),
+ // Make sure js sorts it in numeric order
+ array( 'data-sort-value' => $count ),
$this->msg( 'mediastatistics-nfiles' )
->numParams( $count )
/** @todo Check to be sure this really should have number formatting */
@@ -185,6 +190,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 );
@@ -302,6 +310,8 @@ class MediaStatisticsPage extends QueryPage {
*
* @param $skin Skin
* @param $result stdObject Result row
+ * @return bool|string|void
+ * @throws MWException
*/
public function formatResult( $skin, $result ) {
throw new MWException( "unimplemented" );
@@ -310,15 +320,15 @@ class MediaStatisticsPage extends QueryPage {
/**
* Initialize total values so we can figure out percentages later.
*
- * @param $dbr DatabaseBase
+ * @param $dbr IDatabase
* @param $res ResultWrapper
*/
public function preprocessResults( $dbr, $res ) {
$this->totalCount = $this->totalBytes = 0;
foreach ( $res as $row ) {
- list( , , $count, $bytes ) = $this->splitFakeTitle( $row->title );
- $this->totalCount += $count;
- $this->totalBytes += $bytes;
+ $mediaStats = $this->splitFakeTitle( $row->title );
+ $this->totalCount += isset( $mediaStats[2] ) ? $mediaStats[2] : 0;
+ $this->totalBytes += isset( $mediaStats[3] ) ? $mediaStats[3] : 0;
}
$res->seek( 0 );
}