r52152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52151‎ | r52152 | r52153 >
Date:08:03, 19 June 2009
Author:catrope
Status:ok
Tags:
Comment:
API: (bug 14200) Add user and excludeuser to list=recentchanges and list=watchlist. Requires the rc_user_text index, which was finally added on all servers with the recent schema changes.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php
@@ -95,7 +95,7 @@
9696 */
9797 $db = $this->getDB();
9898 $this->addTables('recentchanges');
99 - $this->addOption('USE INDEX', array('recentchanges' => 'rc_timestamp'));
 99+ $index = 'rc_timestamp'; // May change
100100 $this->addWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
101101 $this->addWhereFld('rc_namespace', $params['namespace']);
102102 $this->addWhereFld('rc_deleted', 0);
@@ -134,8 +134,21 @@
135135 // Don't throw log entries out the window here
136136 $this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset ($show['!redirect']));
137137 }
 138+
 139+ if(!is_null($params['user']) && !is_null($param['excludeuser']))
 140+ $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
 141+ if(!is_null($params['user']))
 142+ {
 143+ $this->addWhereFld('rc_user_text', $params['user']);
 144+ $index = 'rc_user_text';
 145+ }
 146+ if(!is_null($params['excludeuser']))
 147+ // We don't use the rc_user_text index here because
 148+ // * it would require us to sort by rc_user_text before rc_timestamp
 149+ // * the != condition doesn't throw out too many rows anyway
 150+ $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
138151
139 - /* Add the fields we're concerned with to out query. */
 152+ /* Add the fields we're concerned with to our query. */
140153 $this->addFields(array (
141154 'rc_timestamp',
142155 'rc_namespace',
@@ -192,6 +205,7 @@
193206 }
194207 $this->token = $params['token'];
195208 $this->addOption('LIMIT', $params['limit'] +1);
 209+ $this->addOption('USE INDEX', array('recentchanges' => $index));
196210
197211 $count = 0;
198212 /* Perform the actual query. */
@@ -374,6 +388,12 @@
375389 ApiBase :: PARAM_ISMULTI => true,
376390 ApiBase :: PARAM_TYPE => 'namespace'
377391 ),
 392+ 'user' => array(
 393+ ApiBase :: PARAM_TYPE => 'user'
 394+ ),
 395+ 'excludeuser' => array(
 396+ ApiBase :: PARAM_TYPE => 'user'
 397+ ),
378398 'prop' => array (
379399 ApiBase :: PARAM_ISMULTI => true,
380400 ApiBase :: PARAM_DFLT => 'title|timestamp|ids',
@@ -433,6 +453,8 @@
434454 'end' => 'The timestamp to end enumerating.',
435455 'dir' => 'In which direction to enumerate.',
436456 'namespace' => 'Filter log entries to only this namespace(s)',
 457+ 'user' => 'Only list changes by this user',
 458+ 'excludeuser' => 'Don\'t list changes by this user',
437459 'prop' => 'Include additional pieces of information',
438460 'token' => 'Which tokens to obtain for each change',
439461 'show' => array (
@@ -457,4 +479,4 @@
458480 public function getVersion() {
459481 return __CLASS__ . ': $Id$';
460482 }
461 -}
\ No newline at end of file
 483+}
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -162,6 +162,13 @@
163163 $this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
164164 $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
165165 }
 166+
 167+ if(!is_null($params['user']) && !is_null($params['excludeuser']))
 168+ $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
 169+ if(!is_null($params['user']))
 170+ $this->addWhereFld('rc_user_text', $params['user']);
 171+ if(!is_null($params['excludeuser']))
 172+ $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
166173
167174
168175 # This is an index optimization for mysql, as done in the Special:Watchlist page
@@ -268,6 +275,12 @@
269276 ApiBase :: PARAM_ISMULTI => true,
270277 ApiBase :: PARAM_TYPE => 'namespace'
271278 ),
 279+ 'user' => array(
 280+ ApiBase :: PARAM_TYPE => 'user',
 281+ ),
 282+ 'excludeuser' => array(
 283+ ApiBase :: PARAM_TYPE => 'user',
 284+ ),
272285 'dir' => array (
273286 ApiBase :: PARAM_DFLT => 'older',
274287 ApiBase :: PARAM_TYPE => array (
@@ -318,6 +331,8 @@
319332 'start' => 'The timestamp to start enumerating from.',
320333 'end' => 'The timestamp to end enumerating.',
321334 'namespace' => 'Filter changes to only the given namespace(s).',
 335+ 'user' => 'Only list changes by this user',
 336+ 'excludeuser' => 'Don\'t list changes by this user',
322337 'dir' => 'In which direction to enumerate pages.',
323338 'limit' => 'How many total results to return per request.',
324339 'prop' => 'Which additional items to get (non-generator mode only).',
@@ -345,4 +360,4 @@
346361 public function getVersion() {
347362 return __CLASS__ . ': $Id$';
348363 }
349 -}
\ No newline at end of file
 364+}
Index: trunk/phase3/RELEASE-NOTES
@@ -223,6 +223,8 @@
224224 * Made deleting file description pages without files possible
225225 * (bug 18773) Add content flag to siprop=namespaces output
226226 * (bug 18785) Add siprop=languages to meta=siteinfo
 227+* (bug 14200) Added user and excludeuser parameters to list=watchlist and
 228+ list=recentchanges
227229
228230 === Languages updated in 1.16 ===
229231

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44718Revert r44716 (added user,excludeuser to watchlist,recentchanges): can't comm...catrope15:35, 17 December 2008

Status & tagging log