r55124 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55123‎ | r55124 | r55125 >
Date:06:23, 16 August 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
(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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRandompage.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRandompage.php
@@ -10,11 +10,9 @@
1111 class RandomPage extends SpecialPage {
1212 private $namespaces; // namespaces to select pages from
1313
14 - function __construct( $name = 'Randompage' ){
 14+ public function __construct( $name = 'Randompage' ){
1515 global $wgContentNamespaces;
16 -
1716 $this->namespaces = $wgContentNamespaces;
18 -
1917 parent::__construct( $name );
2018 }
2119
@@ -44,7 +42,8 @@
4543
4644 if( is_null( $title ) ) {
4745 $this->setHeaders();
48 - $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages', $wgContLang->getNsText( $this->namespace ) );
 46+ $wgOut->addWikiMsg( strtolower( $this->mName ) . '-nopages',
 47+ $this->getNsList(), count( $this->namespaces ) );
4948 return;
5049 }
5150
@@ -52,7 +51,24 @@
5352 $wgOut->redirect( $title->getFullUrl( $query ) );
5453 }
5554
 55+ /**
 56+ * Get a comma-delimited list of namespaces we don't have
 57+ * any pages in
 58+ * @return String
 59+ */
 60+ private function getNsList() {
 61+ global $wgContLang;
 62+ $nsNames = array();
 63+ foreach( $this->namespaces as $n ) {
 64+ if( $n === NS_MAIN )
 65+ $nsNames[] = wfMsgForContent( 'blanknamespace' );
 66+ else
 67+ $nsNames[] = $wgContLang->getNsText( $n );
 68+ }
 69+ return $wgContLang->commaList( $nsNames );
 70+ }
5671
 72+
5773 /**
5874 * Choose a random title.
5975 * @return Title object (or null if nothing to choose from)
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2265,7 +2265,7 @@
22662266
22672267 # Random page
22682268 'randompage' => 'Random page',
2269 -'randompage-nopages' => 'There are no pages in the namespace "$1".',
 2269+'randompage-nopages' => 'There are no pages in the following {{PLURAL:$2|namespace|namespaces}}: $1.',
22702270 'randompage-url' => 'Special:Random', # do not translate or duplicate this message to other languages
22712271
22722272 # Random redirect
Index: trunk/phase3/RELEASE-NOTES
@@ -403,6 +403,8 @@
404404 foo,bar@example,com
405405 * (bug 20176) Fix login/logout links in skin CologneBlue
406406 * (bug 20203) "Powered by Mediawiki" now has height/width on image tag
 407+* (bug 20273) Fix broken output when no pages are found in the content
 408+ namespaces
407409
408410 == API changes in 1.16 ==
409411

Comments

#Comment by Nikerabbit (talk | contribs)   09:32, 16 August 2009
+$nsNames[] = wfMsgForContent( 'blanknamespace' );

Why for content?

Status & tagging log