r30483 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30482‎ | r30483 | r30484 >
Date:19:03, 3 February 2008
Author:catrope
Status:old
Tags:
Comment:
(bug 12875) Adding query-continue to prop=imageinfo. Patch by Bryan Tongh Minh.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -583,10 +583,10 @@
584584 $conds = $opts = array();
585585 $conds[] = "oi_name = " . $dbr->addQuotes( $this->title->getDBKey() );
586586 if( $start !== null ) {
587 - $conds[] = "oi_timestamp < '" . $dbr->timestamp( $start ) . "'";
 587+ $conds[] = "oi_timestamp <= '" . $dbr->timestamp( $start ) . "'";
588588 }
589589 if( $end !== null ) {
590 - $conds[] = "oi_timestamp > '" . $dbr->timestamp( $end ). "'";
 590+ $conds[] = "oi_timestamp >= '" . $dbr->timestamp( $end ). "'";
591591 }
592592 if( $limit ) {
593593 $opts['LIMIT'] = $limit;
Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -79,11 +79,16 @@
8080 }
8181
8282 // Now get the old revisions
83 - if($params['limit'] > count($data)) {
84 - $oldies = $img->getHistory($params['limit'] - count($data), $params['start'], $params['end']);
85 - if(!empty($oldies))
86 - foreach($oldies as $oldie)
87 - $data[] = $this->getInfo($oldie);
 83+ // Get one more to facilitate query-continue functionality
 84+ $count = count($data);
 85+ $oldies = $img->getHistory($params['limit'] - count($data) + 1, $params['start'], $params['end']);
 86+ foreach($oldies as $oldie) {
 87+ if(++$count > $params['limit']) {
 88+ // We've reached the extra one which shows that there are additional pages to be had. Stop here...
 89+ $this->setContinueEnumParameter('start', $oldie->getTimestamp());
 90+ break;
 91+ }
 92+ $data[] = $this->getInfo($oldie);
8893 }
8994 }
9095

Status & tagging log

  NODES