r23797 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23796‎ | r23797 | r23798 >
Date:19:43, 6 July 2007
Author:yurik
Status:old
Tags:
Comment:
API: Fixed continuation bug in list=categorymembers. Thanks to Roberto Leandrini.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -64,11 +64,11 @@
6565 $fld_sortkey = isset($prop['sortkey']);
6666
6767 if (is_null($resultPageSet)) {
68 - $this->addFields(array('cl_sortkey', 'page_namespace', 'page_title'));
 68+ $this->addFields(array('cl_from', 'cl_sortkey', 'page_namespace', 'page_title'));
6969 $this->addFieldsIf('page_id', $fld_ids);
7070 } else {
7171 $this->addFields($resultPageSet->getPageTableFields()); // will include page_ id, ns, title
72 - $this->addFields('cl_sortkey');
 72+ $this->addFields(array('cl_from', 'cl_sortkey'));
7373 }
7474
7575 $this->addTables(array('page','categorylinks')); // must be in this order for 'USE INDEX'
@@ -139,18 +139,24 @@
140140 return; // This is not a continuation request
141141
142142 $continueList = explode('|', $continue);
143 - if (count($continueList) != 2)
 143+ $hasError = count($continueList) != 2;
 144+ $from = 0;
 145+ if (!$hasError && strlen($continueList[1]) > 0) {
 146+ $from = intval($continueList[1]);
 147+ $hasError = ($from == 0);
 148+ }
 149+
 150+ if ($hasError)
144151 $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "badcontinue");
145152
146153 $sortKey = $this->getDB()->addQuotes($continueList[0]);
147 - $from = intval($continueList[1]);
148154
149155 if ($from != 0) {
150156 // Duplicate sort key continue
151157 $this->addWhere( "cl_sortkey>$sortKey OR (cl_sortkey=$sortKey AND cl_from>=$from)" );
152158 } else {
153159 $this->addWhere( "cl_sortkey>=$sortKey" );
154 - }
 160+ }
155161 }
156162
157163 protected function getAllowedParams() {
@@ -183,7 +189,7 @@
184190 protected function getParamDescription() {
185191 return array (
186192 'category' => 'Which category to enumerate (required)',
187 - 'prop' => 'What pieces of infromation to include',
 193+ 'prop' => 'What pieces of information to include',
188194 'namespace' => 'Only include pages in these namespaces',
189195 'continue' => 'For large categories, give the value retured from previous query',
190196 'limit' => 'The maximum number of pages to return.',

Follow-up revisions

RevisionCommit summaryAuthorDate
r23912Merged revisions 23662-23909 via svnmerge from...david18:11, 9 July 2007

Status & tagging log