From 6145465e34a26d498cdca0a196cc025213127c9f Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 10 Feb 2009 12:32:22 +0000 Subject: [PATCH] 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 --- includes/api/ApiQueryRevisions.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index e8f55c0c7c..7bad086b9c 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -208,6 +208,10 @@ class ApiQueryRevisions extends ApiQueryBase { // Get all revision IDs $this->addWhereFld('rev_id', array_keys($revs)); + if(!is_null($params['continue'])) + $this->addWhere("rev_id >= '" . intval($params['continue']) . "'"); + $this->addOption('ORDER BY', 'rev_id'); + // assumption testing -- we should never get more then $revCount rows. $limit = $revCount; } @@ -225,14 +229,26 @@ class ApiQueryRevisions extends ApiQueryBase { // Get all page IDs $this->addWhereFld('page_id', array_keys($titles)); + if(!is_null($params['continue'])) + { + $cont = explode('|', $params['continue']); + if(count($cont) != 2) + $this->dieUsage("Invalid continue param. You should pass the original " . + "value returned by the previous query", "_badcontinue"); + $pageid = intval($cont[0]); + $revid = intval($cont[1]); + $this->addWhere("rev_page > '$pageid' OR " . + "(rev_page = '$pageid' AND " . + "rev_id >= '$revid')"); + } + $this->addOption('ORDER BY', 'rev_page, rev_id'); + // assumption testing -- we should never get more then $pageCount rows. $limit = $pageCount; } else ApiBase :: dieDebug(__METHOD__, 'param validation?'); $this->addOption('LIMIT', $limit +1); - if(!is_null($params['continue'])) - $this->addOption('OFFSET', $params['continue']); $data = array (); $count = 0; @@ -255,8 +271,11 @@ class ApiQueryRevisions extends ApiQueryBase { { if($enumRevMode) $this->setContinueEnumParameter('startid', intval($row->rev_id)); + else if($revCount > 0) + $this->setContinueEnumParameter('continue', intval($row->rev_id)); else - $this->setContinueEnumParameter('continue', $params['continue'] + $count - 1); + $this->setContinueEnumParameter('continue', intval($row->rev_page) . + '|' . intval($row->rev_id)); break; } } -- 2.20.1