From 0d5b7c3a1d11c8decfb993918b734189afe17c6c Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 3 Feb 2008 19:03:01 +0000 Subject: [PATCH] (bug 12875) Adding query-continue to prop=imageinfo. Patch by Bryan Tongh Minh. --- includes/api/ApiQueryImageInfo.php | 15 ++++++++++----- includes/filerepo/LocalFile.php | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 5a2a32d04e..0e214db3f8 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -79,11 +79,16 @@ class ApiQueryImageInfo extends ApiQueryBase { } // Now get the old revisions - if($params['limit'] > count($data)) { - $oldies = $img->getHistory($params['limit'] - count($data), $params['start'], $params['end']); - if(!empty($oldies)) - foreach($oldies as $oldie) - $data[] = $this->getInfo($oldie); + // Get one more to facilitate query-continue functionality + $count = count($data); + $oldies = $img->getHistory($params['limit'] - count($data) + 1, $params['start'], $params['end']); + foreach($oldies as $oldie) { + if(++$count > $params['limit']) { + // We've reached the extra one which shows that there are additional pages to be had. Stop here... + $this->setContinueEnumParameter('start', $oldie->getTimestamp()); + break; + } + $data[] = $this->getInfo($oldie); } } diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index c09da7c04a..3b936a6926 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -583,10 +583,10 @@ class LocalFile extends File $conds = $opts = array(); $conds[] = "oi_name = " . $dbr->addQuotes( $this->title->getDBKey() ); if( $start !== null ) { - $conds[] = "oi_timestamp < '" . $dbr->timestamp( $start ) . "'"; + $conds[] = "oi_timestamp <= '" . $dbr->timestamp( $start ) . "'"; } if( $end !== null ) { - $conds[] = "oi_timestamp > '" . $dbr->timestamp( $end ). "'"; + $conds[] = "oi_timestamp >= '" . $dbr->timestamp( $end ). "'"; } if( $limit ) { $opts['LIMIT'] = $limit; -- 2.20.1