From 00483cd3478efada7825edb9306a8e230d042792 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 16 Aug 2009 06:23:07 +0000 Subject: [PATCH] (bug 20273) Undefined variable in Special:RandomPage. Fix this output entirely, build a proper list of the content namespaces on the off chance there's no pages in any of them. --- RELEASE-NOTES | 2 ++ includes/specials/SpecialRandompage.php | 24 ++++++++++++++++++++---- languages/messages/MessagesEn.php | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bc6a4d60d1..deb38c5536 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -403,6 +403,8 @@ this. Was used when mwEmbed was going to be an extension. foo,bar@example,com * (bug 20176) Fix login/logout links in skin CologneBlue * (bug 20203) "Powered by Mediawiki" now has height/width on image tag +* (bug 20273) Fix broken output when no pages are found in the content + namespaces == API changes in 1.16 == diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index af43e9c605..ce2a8c015c 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -10,11 +10,9 @@ class RandomPage extends SpecialPage { private $namespaces; // namespaces to select pages from - function __construct( $name = 'Randompage' ){ + public function __construct( $name = 'Randompage' ){ global $wgContentNamespaces; - $this->namespaces = $wgContentNamespaces; - parent::__construct( $name ); } @@ -44,7 +42,8 @@ class RandomPage extends SpecialPage { if( is_null( $title ) ) { $this->setHeaders(); - $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages', $wgContLang->getNsText( $this->namespace ) ); + $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages', + $this->getNsList(), count( $this->namespaces ) ); return; } @@ -52,6 +51,23 @@ class RandomPage extends SpecialPage { $wgOut->redirect( $title->getFullUrl( $query ) ); } + /** + * Get a comma-delimited list of namespaces we don't have + * any pages in + * @return String + */ + private function getNsList() { + global $wgContLang; + $nsNames = array(); + foreach( $this->namespaces as $n ) { + if( $n === NS_MAIN ) + $nsNames[] = wfMsgForContent( 'blanknamespace' ); + else + $nsNames[] = $wgContLang->getNsText( $n ); + } + return $wgContLang->commaList( $nsNames ); + } + /** * Choose a random title. diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 13fb9cb50d..ec98484e5a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2265,7 +2265,7 @@ Remember to check for other links to the templates before deleting them.', # Random page 'randompage' => 'Random page', -'randompage-nopages' => 'There are no pages in the namespace "$1".', +'randompage-nopages' => 'There are no pages in the following {{PLURAL:$2|namespace|namespaces}}: $1.', 'randompage-url' => 'Special:Random', # do not translate or duplicate this message to other languages # Random redirect -- 2.20.1