Merge "Add List-Unsubscribe header to emails"
[lhc/web/wiklou.git] / includes / specials / SpecialMediaStatistics.php
index c26adc5..8f14a41 100644 (file)
@@ -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',
@@ -107,7 +111,11 @@ class MediaStatisticsPage extends QueryPage {
        protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
                $prevMediaType = null;
                foreach ( $res as $row ) {
-                       list( $mediaType, $mime, $totalCount, $totalBytes ) = $this->splitFakeTitle( $row->title );
+                       $mediaStats = $this->splitFakeTitle( $row->title );
+                       if ( count( $mediaStats ) < 4 ) {
+                               continue;
+                       }
+                       list( $mediaType, $mime, $totalCount, $totalBytes ) = $mediaStats;
                        if ( $prevMediaType !== $mediaType ) {
                                if ( $prevMediaType !== null ) {
                                        // We're not at beginning, so we have to
@@ -306,6 +314,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" );
@@ -320,9 +330,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 );
        }