(bug 20273) Undefined variable in Special:RandomPage. Fix this output entirely, build...
authorChad Horohoe <demon@users.mediawiki.org>
Sun, 16 Aug 2009 06:23:07 +0000 (06:23 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sun, 16 Aug 2009 06:23:07 +0000 (06:23 +0000)
RELEASE-NOTES
includes/specials/SpecialRandompage.php
languages/messages/MessagesEn.php

index bc6a4d6..deb38c5 100644 (file)
@@ -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 ==
 
index af43e9c..ce2a8c0 100644 (file)
 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.
index 13fb9cb..ec98484 100644 (file)
@@ -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