From 93a87725aef6bb57f12805fd8e089eaf564b541b Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Fri, 23 Aug 2013 13:02:49 -0700 Subject: [PATCH] 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 --- includes/specials/SpecialRandomInCategory.php | 5 +++++ 1 file changed, 5 insertions(+) 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 ); } -- 2.20.1