From ff1354373cb33806ee49fe92b31ddf69b2811d68 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 26 Jun 2008 15:48:44 +0000 Subject: [PATCH] Use the proper Title methods in ApiQueryBase::titleToKey() and keyToTitle(). This fixes bug 14651 for much more than just apprefix. --- RELEASE-NOTES | 1 + includes/api/ApiQueryBase.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7fec797712..953d72f62e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -469,6 +469,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added nocreate parameter to action=edit * (bug 14402) Added maxage and smaxage parameters to api.php * Added bkip parameter to list=blocks +* (bug 14651) apprefix and similar parameters are now canonicalized === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index e1d9fc3cdf..b17cfabe47 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -319,14 +319,13 @@ abstract class ApiQueryBase extends ApiBase { } /** - * This is a very simplistic utility function - * to convert a non-namespaced title string to a db key. - * It will replace all ' ' with '_' + * Convert a title to a DB key * @param string $title Page title with spaces * @return string Page title with underscores */ public static function titleToKey($title) { - return str_replace(' ', '_', $title); + $t = Title::newFromText($title); + return $t->getDbKey(); } /** @@ -335,7 +334,8 @@ abstract class ApiQueryBase extends ApiBase { * @return string Page title with spaces */ public static function keyToTitle($key) { - return str_replace('_', ' ', $key); + $t = Title::newFromDbKey($key); + return $t->getPrefixedText(); } /** -- 2.20.1