* @file
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- // Eclipse helper - will be ignored in production
- require_once( 'ApiQueryBase.php' );
-}
-
/**
* A query action to enumerate the recent changes that were done to the wiki.
* Various filters are supported.
* Get an array mapping token names to their handler functions.
* The prototype for a token function is func($pageid, $title, $rc)
* it should return a token or false (permission denied)
- * @return array(tokenname => function)
+ * @return array array(tokenname => function)
*/
protected function getTokenFunctions() {
// Don't call the hooks twice
// The patrol token is always the same, let's exploit that
static $cachedPatrolToken = null;
if ( is_null( $cachedPatrolToken ) ) {
- $cachedPatrolToken = $wgUser->editToken( 'patrol' );
+ $cachedPatrolToken = $wgUser->getEditToken( 'patrol' );
}
return $cachedPatrolToken;
* @param $resultPageSet ApiPageSet
*/
public function run( $resultPageSet = null ) {
- global $wgUser;
+ $user = $this->getUser();
/* Get the parameters of the request. */
$params = $this->extractRequestParams();
*/
$this->addTables( 'recentchanges' );
$index = array( 'recentchanges' => 'rc_timestamp' ); // May change
- $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
+ $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
$this->addWhereFld( 'rc_namespace', $params['namespace'] );
$this->addWhereFld( 'rc_deleted', 0 );
// Check permissions
if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
- if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
+ if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
$this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
}
}
/* Set up internal members based upon params. */
$this->initProperties( $prop );
- if ( $this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
+ if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
$this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
}
/* Add fields to our query if they are specified as a needed parameter. */
- $this->addFieldsIf( 'rc_id', $this->fld_ids );
- $this->addFieldsIf( 'rc_this_oldid', $this->fld_ids );
- $this->addFieldsIf( 'rc_last_oldid', $this->fld_ids );
+ $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
$this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
$this->addFieldsIf( 'rc_user', $this->fld_user );
$this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
- $this->addFieldsIf( 'rc_minor', $this->fld_flags );
- $this->addFieldsIf( 'rc_bot', $this->fld_flags );
- $this->addFieldsIf( 'rc_new', $this->fld_flags );
- $this->addFieldsIf( 'rc_old_len', $this->fld_sizes );
- $this->addFieldsIf( 'rc_new_len', $this->fld_sizes );
+ $this->addFieldsIf( array( 'rc_minor', 'rc_new', 'rc_bot' ) , $this->fld_flags );
+ $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
$this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
- $this->addFieldsIf( 'rc_logid', $this->fld_loginfo );
- $this->addFieldsIf( 'rc_log_type', $this->fld_loginfo );
- $this->addFieldsIf( 'rc_log_action', $this->fld_loginfo );
- $this->addFieldsIf( 'rc_params', $this->fld_loginfo );
+ $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
$showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] );
}
$titles = array();
+ $result = $this->getResult();
+
/* Iterate through the rows, adding data extracted from them to our query result. */
foreach ( $res as $row ) {
if ( ++ $count > $params['limit'] ) {
if ( !$vals ) {
continue;
}
- $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
break;
if ( is_null( $resultPageSet ) ) {
/* Format the result */
- $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'rc' );
} else {
$resultPageSet->populateFromTitles( $titles );
}
}
if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
- global $wgUser;
- $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rc_comment, $title );
+ $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
}
if ( $this->fld_redirect ) {
) );
}
- protected function getExamples() {
+ public function getExamples() {
return array(
'api.php?action=query&list=recentchanges'
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Recentchanges';
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}