*/
$db = $this->getDB();
$this->addTables('recentchanges');
- $this->addOption('USE INDEX', array('recentchanges' => 'rc_timestamp'));
+ $index = 'rc_timestamp'; // May change
$this->addWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
$this->addWhereFld('rc_namespace', $params['namespace']);
$this->addWhereFld('rc_deleted', 0);
// Don't throw log entries out the window here
$this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset ($show['!redirect']));
}
+
+ if(!is_null($params['user']) && !is_null($param['excludeuser']))
+ $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
+ if(!is_null($params['user']))
+ {
+ $this->addWhereFld('rc_user_text', $params['user']);
+ $index = 'rc_user_text';
+ }
+ if(!is_null($params['excludeuser']))
+ // We don't use the rc_user_text index here because
+ // * it would require us to sort by rc_user_text before rc_timestamp
+ // * the != condition doesn't throw out too many rows anyway
+ $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
- /* Add the fields we're concerned with to out query. */
+ /* Add the fields we're concerned with to our query. */
$this->addFields(array (
'rc_timestamp',
'rc_namespace',
}
$this->token = $params['token'];
$this->addOption('LIMIT', $params['limit'] +1);
+ $this->addOption('USE INDEX', array('recentchanges' => $index));
$count = 0;
/* Perform the actual query. */
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_TYPE => 'namespace'
),
+ 'user' => array(
+ ApiBase :: PARAM_TYPE => 'user'
+ ),
+ 'excludeuser' => array(
+ ApiBase :: PARAM_TYPE => 'user'
+ ),
'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_DFLT => 'title|timestamp|ids',
'end' => 'The timestamp to end enumerating.',
'dir' => 'In which direction to enumerate.',
'namespace' => 'Filter log entries to only this namespace(s)',
+ 'user' => 'Only list changes by this user',
+ 'excludeuser' => 'Don\'t list changes by this user',
'prop' => 'Include additional pieces of information',
'token' => 'Which tokens to obtain for each change',
'show' => array (
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
$this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
$this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
}
+
+ if(!is_null($params['user']) && !is_null($params['excludeuser']))
+ $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
+ if(!is_null($params['user']))
+ $this->addWhereFld('rc_user_text', $params['user']);
+ if(!is_null($params['excludeuser']))
+ $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
# This is an index optimization for mysql, as done in the Special:Watchlist page
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_TYPE => 'namespace'
),
+ 'user' => array(
+ ApiBase :: PARAM_TYPE => 'user',
+ ),
+ 'excludeuser' => array(
+ ApiBase :: PARAM_TYPE => 'user',
+ ),
'dir' => array (
ApiBase :: PARAM_DFLT => 'older',
ApiBase :: PARAM_TYPE => array (
'start' => 'The timestamp to start enumerating from.',
'end' => 'The timestamp to end enumerating.',
'namespace' => 'Filter changes to only the given namespace(s).',
+ 'user' => 'Only list changes by this user',
+ 'excludeuser' => 'Don\'t list changes by this user',
'dir' => 'In which direction to enumerate pages.',
'limit' => 'How many total results to return per request.',
'prop' => 'Which additional items to get (non-generator mode only).',
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}