From 7147b264bc502f2447208006ecd2c288def4e8bf Mon Sep 17 00:00:00 2001 From: X! Date: Fri, 6 Aug 2010 18:58:10 +0000 Subject: [PATCH] * (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages, allpages, and allusers --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryAllCategories.php | 10 ++++++++-- includes/api/ApiQueryAllLinks.php | 5 +++++ includes/api/ApiQueryAllUsers.php | 5 +++++ includes/api/ApiQueryAllimages.php | 10 ++++++++-- includes/api/ApiQueryAllmessages.php | 7 +++++++ includes/api/ApiQueryAllpages.php | 9 +++++++-- 7 files changed, 42 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8b77262914..8f00131c0c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -326,6 +326,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN the parameter, the API will automatically throw an error. * (bug 24665) When starttimestamp is not specified, fake it by setting it to NOW, not to the timestamp of the last edit +* (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages, + allpages, and allusers === Languages updated in 1.17 === diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index afdc52da5e..a549294a0a 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -59,9 +59,13 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $this->addTables( 'category' ); $this->addFields( 'cat_title' ); - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' ); $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); - $this->addWhereRange( 'cat_title', $dir, $from, null ); + $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); + $this->addWhereRange( 'cat_title', $fromdir, $from, null ); + $this->addWhereRange( 'cat_title', $todir, $to, null ); + if ( isset( $params['prefix'] ) ) { $this->addWhere( 'cat_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } @@ -132,6 +136,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { public function getAllowedParams() { return array( 'from' => null, + 'to' => null, 'prefix' => null, 'dir' => array( ApiBase::PARAM_DFLT => 'ascending', @@ -158,6 +163,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { public function getParamDescription() { return array( 'from' => 'The category to start enumerating from', + 'to' => 'The category to stop enumerating at', 'prefix' => 'Search for all category titles that begin with this value', 'dir' => 'Direction to sort in', 'limit' => 'How many categories to return', diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 40c63f81cb..cb6243869f 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -92,6 +92,9 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { if ( !is_null( $params['from'] ) ) { $this->addWhere( 'pl_title>=' . $db->addQuotes( $this->titlePartToKey( $params['from'] ) ) ); } + if ( !is_null( $params['to'] ) ) { + $this->addWhere( 'pl_title<=' . $db->addQuotes( $this->titlePartToKey( $params['to'] ) ) ); + } if ( isset( $params['prefix'] ) ) { $this->addWhere( 'pl_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); } @@ -161,6 +164,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { return array( 'continue' => null, 'from' => null, + 'to' => null, 'prefix' => null, 'unique' => false, 'prop' => array( @@ -189,6 +193,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { $p = $this->getModulePrefix(); return array( 'from' => 'The page title to start enumerating from', + 'to' => 'The page title to stop enumerating at', 'prefix' => 'Search for all page titles that begin with this value', 'unique' => "Only show unique links. Cannot be used with generator or {$p}prop=ids", 'prop' => array( diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 1f4d858a7f..8ff0eade91 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -61,6 +61,9 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( !is_null( $params['from'] ) ) { $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) ); } + if ( !is_null( $params['to'] ) ) { + $this->addWhere( 'u1.user_name <= ' . $db->addQuotes( $this->keyToTitle( $params['to'] ) ) ); + } if ( !is_null( $params['prefix'] ) ) { $this->addWhere( 'u1.user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); @@ -191,6 +194,7 @@ class ApiQueryAllUsers extends ApiQueryBase { public function getAllowedParams() { return array( 'from' => null, + 'to' => null, 'prefix' => null, 'group' => array( ApiBase::PARAM_TYPE => User::getAllGroups() @@ -218,6 +222,7 @@ class ApiQueryAllUsers extends ApiQueryBase { public function getParamDescription() { return array( 'from' => 'The user name to start enumerating from', + 'to' => 'The user name to stop enumerating at', 'prefix' => 'Search for all page titles that begin with this value', 'group' => 'Limit users to a given group name', 'prop' => array( diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index a63edecc2c..863cd59ff4 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -78,9 +78,13 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { $params = $this->extractRequestParams(); // Image filters - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' ); $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); - $this->addWhereRange( 'img_name', $dir, $from, null ); + $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); + $this->addWhereRange( 'img_name', $fromdir, $from, null ); + $this->addWhereRange( 'img_name', $todir, $to, null ); + if ( isset( $params['prefix'] ) ) $this->addWhere( 'img_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); @@ -149,6 +153,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { public function getAllowedParams() { return array ( 'from' => null, + 'to' => null, 'prefix' => null, 'minsize' => array( ApiBase::PARAM_TYPE => 'integer', @@ -183,6 +188,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { public function getParamDescription() { return array( 'from' => 'The image title to start enumerating from', + 'to' => 'The image title to stop enumerating at', 'prefix' => 'Search for all image titles that begin with this value', 'dir' => 'The direction in which to list', 'minsize' => 'Limit to images with at least this many bytes', diff --git a/includes/api/ApiQueryAllmessages.php b/includes/api/ApiQueryAllmessages.php index 39b736b4ac..b84d3f6b66 100644 --- a/includes/api/ApiQueryAllmessages.php +++ b/includes/api/ApiQueryAllmessages.php @@ -76,12 +76,17 @@ class ApiQueryAllmessages extends ApiQueryBase { // Get all requested messages and print the result $skip = !is_null( $params['from'] ); + $useto = !is_null( $params['to'] ); $result = $this->getResult(); foreach ( $messages_target as $message ) { // Skip all messages up to $params['from'] if ( $skip && $message === $params['from'] ) { $skip = false; } + + if( $useto && $message > $params['to'] ) { + break; + } if ( !$skip ) { $a = array( 'name' => $message ); @@ -160,6 +165,7 @@ class ApiQueryAllmessages extends ApiQueryBase { 'filter' => array(), 'lang' => null, 'from' => null, + 'to' => null, ); } @@ -173,6 +179,7 @@ class ApiQueryAllmessages extends ApiQueryBase { 'filter' => 'Return only messages that contain this string', 'lang' => 'Return messages in this language', 'from' => 'Return messages starting at this message', + 'to' => 'Return messages ending at this message', ); } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 571264ae39..7b2a4748d5 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -70,9 +70,12 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { } $this->addWhereFld( 'page_namespace', $params['namespace'] ); - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); + $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' ); $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); - $this->addWhereRange( 'page_title', $dir, $from, null ); + $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) ); + $this->addWhereRange( 'page_title', $fromdir, $from, null ); + $this->addWhereRange( 'page_title', $todir, $to, null ); if ( isset( $params['prefix'] ) ) { $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); @@ -189,6 +192,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { return array( 'from' => null, + 'to' => null, 'prefix' => null, 'namespace' => array( ApiBase::PARAM_DFLT => 0, @@ -253,6 +257,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { $p = $this->getModulePrefix(); return array( 'from' => 'The page title to start enumerating from', + 'to' => 'The page title to stop enumerating at', 'prefix' => 'Search for all page titles that begin with this value', 'namespace' => 'The namespace to enumerate', 'filterredir' => 'Which pages to list', -- 2.20.1