From a827b09904c3ac508922c3f5a6d8e262cc606ac8 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 7 Feb 2015 19:18:45 +0100 Subject: [PATCH] Skip file count on Special:Statistics when no files and no upload There is no need to show the number of zero files on Special:Statistics when it is not possible to upload files, but it is needed, when some files already uploaded even if the upload is disabled later. Change-Id: I4431166ebc8e952e5d926d874b56c743bebcbef1 --- includes/specials/SpecialStatistics.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index 1f339d1ed0..0acbf95b59 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -126,7 +126,7 @@ class SpecialStatistics extends SpecialPage { * @return string */ private function getPageStats() { - return Xml::openElement( 'tr' ) . + $pageStatsHtml = Xml::openElement( 'tr' ) . Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-pages' )->parse() ) . Xml::closeElement( 'tr' ) . $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'Allpages' ), @@ -136,11 +136,17 @@ class SpecialStatistics extends SpecialPage { $this->formatRow( $this->msg( 'statistics-pages' )->parse(), $this->getLanguage()->formatNum( $this->total ), array( 'class' => 'mw-statistics-pages' ), - 'statistics-pages-desc' ) . - $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'MediaStatistics' ), - $this->msg( 'statistics-files' )->parse() ), - $this->getLanguage()->formatNum( $this->images ), - array( 'class' => 'mw-statistics-files' ) ); + 'statistics-pages-desc' ); + + // Show the image row only, when there are files or upload is possible + if ( $this->images !== 0 || $this->getConfig()->get( 'EnableUploads' ) ) { + $pageStatsHtml .= $this->formatRow( Linker::linkKnown( SpecialPage::getTitleFor( 'MediaStatistics' ), + $this->msg( 'statistics-files' )->parse() ), + $this->getLanguage()->formatNum( $this->images ), + array( 'class' => 'mw-statistics-files' ) ); + } + + return $pageStatsHtml; } private function getEditStats() { -- 2.20.1