Allow specifying a random page only in main namespace
authorBrian Wolff <bawolff+wn@gmail.com>
Fri, 20 Jun 2014 14:38:22 +0000 (11:38 -0300)
committerLegoktm <legoktm.wikipedia@gmail.com>
Thu, 24 Jul 2014 02:26:21 +0000 (02:26 +0000)
Make Special:Random/ get you a page in NS_MAIN. Previously it
got a page in the content namespaces. Special:Random (no /) still
returns pages from all content namespaces.

This also affects Special:RandomRootPage from the RandomRootPage
extension.

Bug: 46420
Change-Id: I9ce66b534b86eaa09236dd56dab7ac18d1ef37ec

includes/specials/SpecialRandompage.php

index 24b363d..6d8f59b 100644 (file)
@@ -56,7 +56,9 @@ class RandomPage extends SpecialPage {
        public function execute( $par ) {
                global $wgContLang;
 
-               if ( $par ) {
+               if ( is_string( $par ) ) {
+                       // Testing for stringiness since we want to catch
+                       // the empty string to mean main namespace only.
                        $this->setNamespace( $wgContLang->getNsIndex( $par ) );
                }