r70584 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70583‎ | r70584 | r70585 >
Date:18:58, 6 August 2010
Author:soxred93
Status:resolved (Comments)
Tags:
Comment:
* (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages, allpages, and allusers
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllCategories.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllimages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllLinks.php
@@ -92,6 +92,9 @@
9393 if ( !is_null( $params['from'] ) ) {
9494 $this->addWhere( 'pl_title>=' . $db->addQuotes( $this->titlePartToKey( $params['from'] ) ) );
9595 }
 96+ if ( !is_null( $params['to'] ) ) {
 97+ $this->addWhere( 'pl_title<=' . $db->addQuotes( $this->titlePartToKey( $params['to'] ) ) );
 98+ }
9699 if ( isset( $params['prefix'] ) ) {
97100 $this->addWhere( 'pl_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
98101 }
@@ -161,6 +164,7 @@
162165 return array(
163166 'continue' => null,
164167 'from' => null,
 168+ 'to' => null,
165169 'prefix' => null,
166170 'unique' => false,
167171 'prop' => array(
@@ -189,6 +193,7 @@
190194 $p = $this->getModulePrefix();
191195 return array(
192196 'from' => 'The page title to start enumerating from',
 197+ 'to' => 'The page title to stop enumerating at',
193198 'prefix' => 'Search for all page titles that begin with this value',
194199 'unique' => "Only show unique links. Cannot be used with generator or {$p}prop=ids",
195200 'prop' => array(
Index: trunk/phase3/includes/api/ApiQueryAllCategories.php
@@ -59,9 +59,13 @@
6060 $this->addTables( 'category' );
6161 $this->addFields( 'cat_title' );
6262
63 - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 63+ $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 64+ $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' );
6465 $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
65 - $this->addWhereRange( 'cat_title', $dir, $from, null );
 66+ $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
 67+ $this->addWhereRange( 'cat_title', $fromdir, $from, null );
 68+ $this->addWhereRange( 'cat_title', $todir, $to, null );
 69+
6670 if ( isset( $params['prefix'] ) ) {
6771 $this->addWhere( 'cat_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
6872 }
@@ -132,6 +136,7 @@
133137 public function getAllowedParams() {
134138 return array(
135139 'from' => null,
 140+ 'to' => null,
136141 'prefix' => null,
137142 'dir' => array(
138143 ApiBase::PARAM_DFLT => 'ascending',
@@ -158,6 +163,7 @@
159164 public function getParamDescription() {
160165 return array(
161166 'from' => 'The category to start enumerating from',
 167+ 'to' => 'The category to stop enumerating at',
162168 'prefix' => 'Search for all category titles that begin with this value',
163169 'dir' => 'Direction to sort in',
164170 'limit' => 'How many categories to return',
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -70,9 +70,12 @@
7171 }
7272
7373 $this->addWhereFld( 'page_namespace', $params['namespace'] );
74 - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 74+ $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 75+ $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' );
7576 $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
76 - $this->addWhereRange( 'page_title', $dir, $from, null );
 77+ $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
 78+ $this->addWhereRange( 'page_title', $fromdir, $from, null );
 79+ $this->addWhereRange( 'page_title', $todir, $to, null );
7780
7881 if ( isset( $params['prefix'] ) ) {
7982 $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
@@ -189,6 +192,7 @@
190193
191194 return array(
192195 'from' => null,
 196+ 'to' => null,
193197 'prefix' => null,
194198 'namespace' => array(
195199 ApiBase::PARAM_DFLT => 0,
@@ -253,6 +257,7 @@
254258 $p = $this->getModulePrefix();
255259 return array(
256260 'from' => 'The page title to start enumerating from',
 261+ 'to' => 'The page title to stop enumerating at',
257262 'prefix' => 'Search for all page titles that begin with this value',
258263 'namespace' => 'The namespace to enumerate',
259264 'filterredir' => 'Which pages to list',
Index: trunk/phase3/includes/api/ApiQueryAllimages.php
@@ -78,9 +78,13 @@
7979 $params = $this->extractRequestParams();
8080
8181 // Image filters
82 - $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 82+ $fromdir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
 83+ $todir = ( $params['dir'] != 'descending' ? 'older' : 'newer' );
8384 $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
84 - $this->addWhereRange( 'img_name', $dir, $from, null );
 85+ $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
 86+ $this->addWhereRange( 'img_name', $fromdir, $from, null );
 87+ $this->addWhereRange( 'img_name', $todir, $to, null );
 88+
8589 if ( isset( $params['prefix'] ) )
8690 $this->addWhere( 'img_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
8791
@@ -149,6 +153,7 @@
150154 public function getAllowedParams() {
151155 return array (
152156 'from' => null,
 157+ 'to' => null,
153158 'prefix' => null,
154159 'minsize' => array(
155160 ApiBase::PARAM_TYPE => 'integer',
@@ -183,6 +188,7 @@
184189 public function getParamDescription() {
185190 return array(
186191 'from' => 'The image title to start enumerating from',
 192+ 'to' => 'The image title to stop enumerating at',
187193 'prefix' => 'Search for all image titles that begin with this value',
188194 'dir' => 'The direction in which to list',
189195 'minsize' => 'Limit to images with at least this many bytes',
Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -76,12 +76,17 @@
7777
7878 // Get all requested messages and print the result
7979 $skip = !is_null( $params['from'] );
 80+ $useto = !is_null( $params['to'] );
8081 $result = $this->getResult();
8182 foreach ( $messages_target as $message ) {
8283 // Skip all messages up to $params['from']
8384 if ( $skip && $message === $params['from'] ) {
8485 $skip = false;
8586 }
 87+
 88+ if( $useto && $message > $params['to'] ) {
 89+ break;
 90+ }
8691
8792 if ( !$skip ) {
8893 $a = array( 'name' => $message );
@@ -160,6 +165,7 @@
161166 'filter' => array(),
162167 'lang' => null,
163168 'from' => null,
 169+ 'to' => null,
164170 );
165171 }
166172
@@ -173,6 +179,7 @@
174180 'filter' => 'Return only messages that contain this string',
175181 'lang' => 'Return messages in this language',
176182 'from' => 'Return messages starting at this message',
 183+ 'to' => 'Return messages ending at this message',
177184 );
178185 }
179186
Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -61,6 +61,9 @@
6262 if ( !is_null( $params['from'] ) ) {
6363 $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) );
6464 }
 65+ if ( !is_null( $params['to'] ) ) {
 66+ $this->addWhere( 'u1.user_name <= ' . $db->addQuotes( $this->keyToTitle( $params['to'] ) ) );
 67+ }
6568
6669 if ( !is_null( $params['prefix'] ) ) {
6770 $this->addWhere( 'u1.user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) );
@@ -191,6 +194,7 @@
192195 public function getAllowedParams() {
193196 return array(
194197 'from' => null,
 198+ 'to' => null,
195199 'prefix' => null,
196200 'group' => array(
197201 ApiBase::PARAM_TYPE => User::getAllGroups()
@@ -218,6 +222,7 @@
219223 public function getParamDescription() {
220224 return array(
221225 'from' => 'The user name to start enumerating from',
 226+ 'to' => 'The user name to stop enumerating at',
222227 'prefix' => 'Search for all page titles that begin with this value',
223228 'group' => 'Limit users to a given group name',
224229 'prop' => array(
Index: trunk/phase3/RELEASE-NOTES
@@ -326,6 +326,8 @@
327327 the parameter, the API will automatically throw an error.
328328 * (bug 24665) When starttimestamp is not specified, fake it by setting it to NOW, not to
329329 the timestamp of the last edit
 330+* (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages,
 331+ allpages, and allusers
330332
331333 === Languages updated in 1.17 ===
332334

Follow-up revisions

RevisionCommit summaryAuthorDate
r70635Followup to r70584: Use fourth parameter of ApiQueryBase::addWhereRange inste...soxred9316:51, 7 August 2010
r83837Cleanup/simplify code added to alllinks in r70584reedy17:36, 13 March 2011

Comments

#Comment by Catrope (talk | contribs)   14:43, 7 August 2010
+		$this->addWhereRange( 'cat_title', $fromdir, $from, null );
+		$this->addWhereRange( 'cat_title', $todir, $to, null );

You know, that fourth parameter to addWhereRange() is there for a reason: addWhereRange( 'cat_title', $dir, $from, $to );

Status & tagging log