(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.

This commit is contained in:
Chad Horohoe 2009-08-16 06:23:07 +00:00
parent f0d3466268
commit 00483cd347
3 changed files with 23 additions and 5 deletions

View 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 ==

View file

@ -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.

View 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