(bug 12875) Adding query-continue to prop=imageinfo. Patch by Bryan Tongh Minh.
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 3 Feb 2008 19:03:01 +0000 (19:03 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 3 Feb 2008 19:03:01 +0000 (19:03 +0000)
includes/api/ApiQueryImageInfo.php
includes/filerepo/LocalFile.php

index 5a2a32d..0e214db 100644 (file)
@@ -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);       
                                        }
                                }
 
index c09da7c..3b936a6 100644 (file)
@@ -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;