From 48ae7ab6ffc7d4078f54103fbbf72dd2166fa32a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 18 Feb 2009 15:26:09 +0000 Subject: [PATCH] * API: (bug 17529) rvend ignored when rvstartid is specified * 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 | 3 ++- includes/api/ApiQueryBase.php | 15 +++++++++------ includes/api/ApiQueryRevisions.php | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8912e9af5f..a0e152e83e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index f7413c24d4..105a20fa3d 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -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); + } } /** diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 7bad086b9c..d3e2125d82 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -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)) -- 2.20.1