SpecialMediaStatistics: Protect against invalid indexes
authorChad Horohoe <chadh@wikimedia.org>
Thu, 12 Feb 2015 19:31:47 +0000 (11:31 -0800)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 13 Feb 2015 16:58:26 +0000 (16:58 +0000)
Sometimes the full string isn't represented, leading to invalid
index access on list()

Just default to 0 since it makes sense here

Change-Id: Icd06d2b22b1fcb57a8849ef6dc8659b424f27fdc

includes/specials/SpecialMediaStatistics.php

index e3c7e3a..1056cda 100644 (file)
@@ -322,9 +322,9 @@ class MediaStatisticsPage extends QueryPage {
        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 );
        }