API: Query-continue prop=categoryinfo by cat_title rather than offset. Suggested...
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 9 Feb 2009 19:54:25 +0000 (19:54 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 9 Feb 2009 19:54:25 +0000 (19:54 +0000)
includes/api/ApiQueryCategoryInfo.php

index 115bd61..a7c4fc4 100644 (file)
@@ -69,17 +69,15 @@ class ApiQueryCategoryInfo extends ApiQueryBase {
                $this->addWhere(array('cat_title' => $cattitles));
                if(!is_null($params['continue']))
                {
-                       // We need to set a LIMIT in order to be able to set
-                       // an OFFSET
-                       $this->addOption('LIMIT', count($titles));
-                       $this->addOption('OFFSET', $params['continue']);
-               }
+                       $title = $this->getDB()->addQuotes($params['continue']);
+                       $this->addWhere("cat_title >= $title");
+               } 
+               $this->addOption('ORDER BY', 'cat_title');
 
                $db = $this->getDB();
                $res = $this->select(__METHOD__);
 
                $catids = array_flip($cattitles);
-               $count = (int)@$params['continue'];
                while($row = $db->fetchObject($res))
                {
                        $vals = array();
@@ -92,10 +90,9 @@ class ApiQueryCategoryInfo extends ApiQueryBase {
                        $fit = $this->addPageSubItems($catids[$row->cat_title], $vals);
                        if(!$fit)
                        {
-                               $this->setContinueEnumParameter('continue', $count);
+                               $this->setContinueEnumParameter('continue', $row->cat_title);
                                break;
                        }
-                       $count++;
                }
                $db->freeResult($res);
        }