(bug 47449) {{#special:}} should always return a usable title
authorMormegil <mormegil@centrum.cz>
Sat, 20 Apr 2013 12:42:22 +0000 (14:42 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 14 Jun 2013 06:33:08 +0000 (06:33 +0000)
{{#special:}} should always return a usable title in NS_SPECIAL,
even when given an unknown special page title. Currently, it returns
"No such special page" text for such unknown names, which is
surprising.

Bug: 47449
Change-Id: I7f184956ec9d56c849f201f1230736fcedd0fadf

includes/parser/CoreParserFunctions.php
tests/parser/parserTests.txt

index 375ff2b..a7820d4 100644 (file)
@@ -824,7 +824,9 @@ class CoreParserFunctions {
                        $title = SpecialPage::getTitleFor( $page, $subpage );
                        return $title->getPrefixedText();
                } else {
-                       return wfMessage( 'nosuchspecialpage' )->inContentLanguage()->text();
+                       // unknown special page, just use the given text as its title, if at all possible
+                       $title = Title::makeTitleSafe( NS_SPECIAL, $text );
+                       return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
                }
        }
 
index 21a6b86..5c35421 100644 (file)
@@ -7400,9 +7400,9 @@ Special:RecentChanges/param
 !! options
 msg
 !! input
-{{#special:foobarnonexistent}}
+{{#special:foobar nonexistent}}
 !! result
-No such special page
+Special:Foobar nonexistent
 !! end
 
 !! test
@@ -7430,9 +7430,9 @@ Special:RecentChanges/param
 !! options
 msg
 !! input
-{{#speciale:foobarnonexistent}}
+{{#speciale:foobar nonexistent}}
 !! result
-No_such_special_page
+Special:Foobar_nonexistent
 !! end
 
 ###
@@ -13969,6 +13969,19 @@ abc
 </p>
 !! end
 
+!!test
+Special parser function
+!! input
+{{#special:RandomPage}}
+{{#special:BaDtItLe}}
+{{#special:Foobar}}
+!! result
+<p>Special:Random
+Special:Badtitle
+Special:Foobar
+</p>
+!! end
+
 !!test
 Bug 34939 - Case insensitive link parsing ([HttP://])
 !! input