r47078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47077‎ | r47078 | r47079 >
Date:12:32, 10 February 2009
Author:catrope
Status:deferred
Tags:
Comment:
API: Page prop=revisions by rev_id or (rev_page, rev_id), depending on mode, because the offset system potentially sucks. Suggested by Brad Jorsch
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -208,6 +208,10 @@
209209 // Get all revision IDs
210210 $this->addWhereFld('rev_id', array_keys($revs));
211211
 212+ if(!is_null($params['continue']))
 213+ $this->addWhere("rev_id >= '" . intval($params['continue']) . "'");
 214+ $this->addOption('ORDER BY', 'rev_id');
 215+
212216 // assumption testing -- we should never get more then $revCount rows.
213217 $limit = $revCount;
214218 }
@@ -225,14 +229,26 @@
226230 // Get all page IDs
227231 $this->addWhereFld('page_id', array_keys($titles));
228232
 233+ if(!is_null($params['continue']))
 234+ {
 235+ $cont = explode('|', $params['continue']);
 236+ if(count($cont) != 2)
 237+ $this->dieUsage("Invalid continue param. You should pass the original " .
 238+ "value returned by the previous query", "_badcontinue");
 239+ $pageid = intval($cont[0]);
 240+ $revid = intval($cont[1]);
 241+ $this->addWhere("rev_page > '$pageid' OR " .
 242+ "(rev_page = '$pageid' AND " .
 243+ "rev_id >= '$revid')");
 244+ }
 245+ $this->addOption('ORDER BY', 'rev_page, rev_id');
 246+
229247 // assumption testing -- we should never get more then $pageCount rows.
230248 $limit = $pageCount;
231249 } else
232250 ApiBase :: dieDebug(__METHOD__, 'param validation?');
233251
234252 $this->addOption('LIMIT', $limit +1);
235 - if(!is_null($params['continue']))
236 - $this->addOption('OFFSET', $params['continue']);
237253
238254 $data = array ();
239255 $count = 0;
@@ -255,8 +271,11 @@
256272 {
257273 if($enumRevMode)
258274 $this->setContinueEnumParameter('startid', intval($row->rev_id));
 275+ else if($revCount > 0)
 276+ $this->setContinueEnumParameter('continue', intval($row->rev_id));
259277 else
260 - $this->setContinueEnumParameter('continue', $params['continue'] + $count - 1);
 278+ $this->setContinueEnumParameter('continue', intval($row->rev_page) .
 279+ '|' . intval($row->rev_id));
261280 break;
262281 }
263282 }

Status & tagging log