From 511ae2aca26da14c0202154731db059e80c750e7 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 25 Aug 2008 05:41:53 +0000 Subject: [PATCH] API: Go back to using the good old str_replace() hacks rather than Title methods in ApiQueryBase::titleToKey() and keyToTitle(). Error handling was awkward and the Title methods over-normalize the input, causing bug 15275 (apprefix ignores spaces at the end) --- RELEASE-NOTES | 1 + includes/api/ApiQueryBase.php | 21 ++------------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3c4d731a4f..f8f4c39415 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -170,6 +170,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN etc. (AKA lists) instead of arrays with pageIDs as keys (AKA hash tables) for consistency with other list modules. * Added action=watch +* (bug 15275) apprefix and related parameters ignore spaces at the end === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index b1e67522f5..b5ceb75e63 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -324,15 +324,7 @@ abstract class ApiQueryBase extends ApiBase { * @return string Page title with underscores */ public function titleToKey($title) { - $t = Title::newFromText($title); - if(!$t) - { - # Don't throw an error if we got an empty string - if($title == '') - return ''; - $this->dieUsageMsg(array('invalidtitle', $title)); - } - return $t->getDbKey(); + return str_replace(' ', '_', $title); } /** @@ -341,16 +333,7 @@ abstract class ApiQueryBase extends ApiBase { * @return string Page title with spaces */ public function keyToTitle($key) { - $t = Title::newFromDbKey($key); - # This really shouldn't happen but we gotta check anyway - if(!$t) - { - # Don't throw an error if we got an empty string - if($key == '') - return ''; - $this->dieUsageMsg(array('invalidtitle', $key)); - } - return $t->getPrefixedText(); + return str_replace('_', ' ', $key); } /** -- 2.20.1