From: Roan Kattouw Date: Tue, 19 Aug 2008 15:05:29 +0000 (+0000) Subject: API: X-Git-Tag: 1.31.0-rc.0~45798 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=309e57fd4a3cf7e5ddd63bcf57f38aca67156e60;p=lhc%2Fweb%2Fwiklou.git API: * BREAKING CHANGE: list={backlinks,embeddedin,imageusage} now return an array with keys 0, 1, 2, ... (list) rather than an array with pageIDs as keys (hash table/associative array) for consistency with other list= modules. * Attempting to fix an error about "Invalid title ``''" (i.e. empty string as title) I encountered at Wikipedia. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3a878092ad..bc8d005022 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -160,6 +160,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN non-hidden categories * (bug 15228) Combining revids= and redirects now throws a warning instead of an error, and still resolves redirects generated by the generator. +* list={backlinks,embeddedin,imageusage} now return arrays with keys 0, 1, 2, + etc. (AKA lists) instead of arrays with pageIDs as keys (AKA hash tables) + for consistency with other list modules. === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 825d5f43b2..a9534512b8 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -229,7 +229,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $resultData = array(); foreach($this->data as $ns => $a) foreach($a as $title => $arr) - $resultData[$arr['pageid']] = $arr; + $resultData[] = $arr; $result = $this->getResult(); $result->setIndexedTagName($resultData, $this->bl_code); $result->addValue('query', $this->getModuleName(), $resultData); diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 31658b1ed1..b1e67522f5 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -326,7 +326,12 @@ abstract class ApiQueryBase extends ApiBase { 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(); } @@ -339,7 +344,12 @@ abstract class ApiQueryBase extends ApiBase { $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(); }