$this->shownavigation = false;
}
- function isExpensive() {
+ public function isExpensive() {
return true;
}
'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',
*
* @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)
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
'mw-mediastats-table-' . strtolower( $mediaType ),
'sortable',
'wikitable'
- ))
+ ) )
)
);
$this->getOutput()->addHTML( $this->getTableHeaderRow() );
array( 'class' => array(
'mw-mediastats-mediatype',
'mw-mediastats-mediatype-' . strtolower( $mediaType )
- )),
+ ) ),
// for grep
// mediastatistics-header-unknown, mediastatistics-header-bitmap,
// mediastatistics-header-drawing, mediastatistics-header-audio,
*
* @param $skin Skin
* @param $result stdObject Result row
+ * @return bool|string|void
+ * @throws MWException
*/
public function formatResult( $skin, $result ) {
throw new MWException( "unimplemented" );
/**
* 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 );
}