* API: (bug 17529) rvend ignored when rvstartid is specified
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 18 Feb 2009 15:26:09 +0000 (15:26 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 18 Feb 2009 15:26:09 +0000 (15:26 +0000)
* To fix this, make the prop=revisions query slightly less performance-zealous and allow WHERE rev_timestamp <= 'foo' when sorting and rangescanning by rev_id
* Make adding ORDER BY in ApiQueryBase::addWhereRange() optional
* Move a RELEASE-NOTES entry to the right section

RELEASE-NOTES
includes/api/ApiQueryBase.php
includes/api/ApiQueryRevisions.php

index 8912e9a..a0e152e 100644 (file)
@@ -189,6 +189,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * File dupe messages for remote repos are now shown only once.
 * (bug 14980) Messages 'shareduploadwiki' and 'shareduploadwiki-desc' are now
   used as a parameter in 'sharedupload' for easier styling and customization.
+* (bug 17482) Formatting error in Special:Preferences#Misc (Opera)
 
 == API changes in 1.15 ==
 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
@@ -223,7 +224,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added mainmodule and pagesetmodule parameters to action=paraminfo
 * (bug 17502) meta=siteinfo&siprop=namespacealiases no longer lists namespace
   aliases already listed in siprop=namespaces
-* (bug 17482) Formatting error in Special:Preferences#Misc (Opera)
+* (bug 17529) rvend ignored when rvstartid is specified
 
 === Languages updated in 1.15 ===
 
index f7413c2..105a20f 100644 (file)
@@ -183,8 +183,9 @@ abstract class ApiQueryBase extends ApiBase {
         *  this is the lower boundary, otherwise it's the upper boundary
         * @param $end string Value to end the list at. If $dir == 'newer' this
         *  is the upper boundary, otherwise it's the lower boundary
+        * @param $sort bool If false, don't add an ORDER BY clause
         */
-       protected function addWhereRange($field, $dir, $start, $end) {
+       protected function addWhereRange($field, $dir, $start, $end, $sort = true) {
                $isDirNewer = ($dir === 'newer');
                $after = ($isDirNewer ? '>=' : '<=');
                $before = ($isDirNewer ? '<=' : '>=');
@@ -196,11 +197,13 @@ abstract class ApiQueryBase extends ApiBase {
                if (!is_null($end))
                        $this->addWhere($field . $before . $db->addQuotes($end));
 
-               $order = $field . ($isDirNewer ? '' : ' DESC');
-               if (!isset($this->options['ORDER BY']))
-                       $this->addOption('ORDER BY', $order);
-               else
-                       $this->addOption('ORDER BY', $this->options['ORDER BY'] . ', ' . $order);
+               if ($sort) {
+                       $order = $field . ($isDirNewer ? '' : ' DESC');
+                       if (!isset($this->options['ORDER BY']))
+                               $this->addOption('ORDER BY', $order);
+                       else
+                               $this->addOption('ORDER BY', $this->options['ORDER BY'] . ', ' . $order);
+               }
        }
 
        /**
index 7bad086..d3e2125 100644 (file)
@@ -176,9 +176,14 @@ class ApiQueryRevisions extends ApiQueryBase {
                        if (is_null($params['startid']) && is_null($params['endid']))
                                $this->addWhereRange('rev_timestamp', $params['dir'],
                                        $params['start'], $params['end']);
-                       else
+                       else {
                                $this->addWhereRange('rev_id', $params['dir'],
                                        $params['startid'], $params['endid']);
+                               // One of start and end can be set
+                               // If neither is set, this does nothing
+                               $this->addWhereRange('rev_timestamp', $params['dir'],
+                                       $params['start'], $params['end'], false);
+                       }
 
                        // must manually initialize unset limit
                        if (is_null($limit))