r36678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36677‎ | r36678 | r36679 >
Date:15:48, 26 June 2008
Author:catrope
Status:old
Tags:
Comment:
Use the proper Title methods in ApiQueryBase::titleToKey() and keyToTitle(). This fixes bug 14651 for much more than just apprefix.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -319,14 +319,13 @@
320320 }
321321
322322 /**
323 - * This is a very simplistic utility function
324 - * to convert a non-namespaced title string to a db key.
325 - * It will replace all ' ' with '_'
 323+ * Convert a title to a DB key
326324 * @param string $title Page title with spaces
327325 * @return string Page title with underscores
328326 */
329327 public static function titleToKey($title) {
330 - return str_replace(' ', '_', $title);
 328+ $t = Title::newFromText($title);
 329+ return $t->getDbKey();
331330 }
332331
333332 /**
@@ -335,7 +334,8 @@
336335 * @return string Page title with spaces
337336 */
338337 public static function keyToTitle($key) {
339 - return str_replace('_', ' ', $key);
 338+ $t = Title::newFromDbKey($key);
 339+ return $t->getPrefixedText();
340340 }
341341
342342 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -469,6 +469,7 @@
470470 * Added nocreate parameter to action=edit
471471 * (bug 14402) Added maxage and smaxage parameters to api.php
472472 * Added bkip parameter to list=blocks
 473+* (bug 14651) apprefix and similar parameters are now canonicalized
473474
474475 === Languages updated in 1.13 ===
475476

Follow-up revisions

RevisionCommit summaryAuthorDate
r36719Fix fatal errors introduced in r36678catrope10:37, 27 June 2008
r36790Fix regression from r36678: we can't use $this->dieUsageMsg() in a static met...catrope22:26, 29 June 2008
r36791Another regression from r36678: dieUsageMsg() expects an array, not varargs.catrope22:29, 29 June 2008
r39936Follow-up for r39935: re-fix bug 14651 by making the first letter uppercase i...catrope05:51, 25 August 2008

Status & tagging log