From: Brian Wolff Date: Fri, 23 Aug 2013 20:02:49 +0000 (-0700) Subject: Make RandomInCat work for cats starting with namespace X-Git-Tag: 1.31.0-rc.0~18890^2 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=93a87725aef6bb57f12805fd8e089eaf564b541b;p=lhc%2Fweb%2Fwiklou.git Make RandomInCat work for cats starting with namespace So if someone has Category:User:Foo, they can go to both Special:RandomInCategory/Category:User:Foo, or just Special:RandomInCategory/User:Foo. Bug: 53239 Change-Id: I2e67f0463b725ce297eeb5a5de73ccbad826907a --- diff --git a/includes/specials/SpecialRandomInCategory.php b/includes/specials/SpecialRandomInCategory.php index 2e4bf2009f..fd554e6462 100644 --- a/includes/specials/SpecialRandomInCategory.php +++ b/includes/specials/SpecialRandomInCategory.php @@ -76,6 +76,11 @@ class SpecialRandomInCategory extends SpecialPage { $cat = Title::newFromText( $categoryStr, NS_CATEGORY ); } + if ( $cat && $cat->getNamespace() !== NS_CATEGORY ) { + // Someone searching for something like "Wikipedia:Foo" + $cat = Title::makeTitleSafe( NS_CATEGORY, $categoryStr ); + } + if ( $cat ) { $this->setCategory( $cat ); }