private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
$fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
$fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false,
- $fld_tags = false, $fld_sha1 = false, $token = array();
+ $fld_tags = false, $fld_sha1 = false, $token = [];
private $tokenFunctions;
// If we're in a mode that breaks the same-origin policy, no tokens can
// be obtained
if ( $this->lacksSameOriginSecurity() ) {
- return array();
+ return [];
}
- $this->tokenFunctions = array(
- 'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
- );
- Hooks::run( 'APIQueryRecentChangesTokens', array( &$this->tokenFunctions ) );
+ $this->tokenFunctions = [
+ 'patrol' => [ 'ApiQueryRecentChanges', 'getPatrolToken' ]
+ ];
+ Hooks::run( 'APIQueryRecentChangesTokens', [ &$this->tokenFunctions ] );
return $this->tokenFunctions;
}
* AND rc_timestamp < $end AND rc_namespace = $namespace
*/
$this->addTables( 'recentchanges' );
- $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
+ $index = [ 'recentchanges' => 'rc_timestamp' ]; // May change
$this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
if ( !is_null( $params['continue'] ) ) {
}
$order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
- $this->addOption( 'ORDER BY', array(
+ $this->addOption( 'ORDER BY', [
"rc_timestamp $order",
"rc_id $order",
- ) );
+ ] );
$this->addWhereFld( 'rc_namespace', $params['namespace'] );
$this->addWhereIf( 'page_is_redirect = 1', isset( $show['redirect'] ) );
if ( isset( $show['unpatrolled'] ) ) {
- // See ChangesList:isUnpatrolled
+ // See ChangesList::isUnpatrolled
if ( $user->useRCPatrol() ) {
$this->addWhere( 'rc_patrolled = 0' );
} elseif ( $user->useNPPatrol() ) {
}
/* Add the fields we're concerned with to our query. */
- $this->addFields( array(
+ $this->addFields( [
'rc_id',
'rc_timestamp',
'rc_namespace',
'rc_cur_id',
'rc_type',
'rc_deleted'
- ) );
+ ] );
$showRedirects = false;
/* Determine what properties we need to display. */
}
/* Add fields to our query if they are specified as a needed parameter. */
- $this->addFieldsIf( array( 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
+ $this->addFieldsIf( [ '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->fld_userid );
$this->addFieldsIf( 'rc_user_text', $this->fld_user );
- $this->addFieldsIf( array( 'rc_minor', 'rc_type', '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_minor', 'rc_type', 'rc_bot' ], $this->fld_flags );
+ $this->addFieldsIf( [ 'rc_old_len', 'rc_new_len' ], $this->fld_sizes );
+ $this->addFieldsIf( [ 'rc_patrolled', 'rc_log_type' ], $this->fld_patrolled );
$this->addFieldsIf(
- array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ),
+ [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ],
$this->fld_loginfo
);
$showRedirects = $this->fld_redirect || isset( $show['redirect'] )
|| isset( $show['!redirect'] );
}
- $this->addFieldsIf( array( 'rc_this_oldid' ),
+ $this->addFieldsIf( [ 'rc_this_oldid' ],
$resultPageSet && $params['generaterevisions'] );
if ( $this->fld_tags ) {
$this->addTables( 'tag_summary' );
- $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
+ $this->addJoinConds( [ 'tag_summary' => [ 'LEFT JOIN', [ 'rc_id=ts_rc_id' ] ] ] );
$this->addFields( 'ts_tags' );
}
if ( $this->fld_sha1 ) {
$this->addTables( 'revision' );
- $this->addJoinConds( array( 'revision' => array( 'LEFT JOIN',
- array( 'rc_this_oldid=rev_id' ) ) ) );
- $this->addFields( array( 'rev_sha1', 'rev_deleted' ) );
+ $this->addJoinConds( [ 'revision' => [ 'LEFT JOIN',
+ [ 'rc_this_oldid=rev_id' ] ] ] );
+ $this->addFields( [ 'rev_sha1', 'rev_deleted' ] );
}
if ( $params['toponly'] || $showRedirects ) {
$this->addTables( 'page' );
- $this->addJoinConds( array( 'page' => array( 'LEFT JOIN',
- array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
+ $this->addJoinConds( [ 'page' => [ 'LEFT JOIN',
+ [ 'rc_namespace=page_namespace', 'rc_title=page_title' ] ] ] );
$this->addFields( 'page_is_redirect' );
if ( $params['toponly'] ) {
if ( !is_null( $params['tag'] ) ) {
$this->addTables( 'change_tag' );
- $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
+ $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
$this->addWhereFld( 'ct_tag', $params['tag'] );
}
$bitmask = 0;
}
if ( $bitmask ) {
- $this->addWhere( $this->getDB()->makeList( array(
+ $this->addWhere( $this->getDB()->makeList( [
'rc_type != ' . RC_LOG,
$this->getDB()->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
- ), LIST_OR ) );
+ ], LIST_OR ) );
}
}
/* Perform the actual query. */
$res = $this->select( __METHOD__ );
- $revids = array();
- $titles = array();
+ $revids = [];
+ $titles = [];
$result = $this->getResult();
$vals = $this->extractRowInfo( $row );
/* Add that row's data to our final output. */
- $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" );
break;
if ( is_null( $resultPageSet ) ) {
/* Format the result */
- $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'rc' );
+ $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'rc' );
} elseif ( $params['generaterevisions'] ) {
$resultPageSet->populateFromRevisionIDs( $revids );
} else {
$user = $this->getUser();
/* Our output data. */
- $vals = array();
+ $vals = [];
$type = intval( $row->rc_type );
$vals['type'] = RecentChange::parseFromRCType( $type );
ApiResult::setIndexedTagName( $tags, 'tag' );
$vals['tags'] = $tags;
} else {
- $vals['tags'] = array();
+ $vals['tags'] = [];
}
}
}
public function getAllowedParams() {
- return array(
- 'start' => array(
+ return [
+ 'start' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'end' => array(
+ ],
+ 'end' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'dir' => array(
+ ],
+ 'dir' => [
ApiBase::PARAM_DFLT => 'older',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'newer',
'older'
- ),
+ ],
ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
- ),
- 'namespace' => array(
+ ],
+ 'namespace' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => 'namespace'
- ),
- 'user' => array(
+ ],
+ 'user' => [
ApiBase::PARAM_TYPE => 'user'
- ),
- 'excludeuser' => array(
+ ],
+ 'excludeuser' => [
ApiBase::PARAM_TYPE => 'user'
- ),
+ ],
'tag' => null,
- 'prop' => array(
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'title|timestamp|ids',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'user',
'userid',
'comment',
'loginfo',
'tags',
'sha1',
- ),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
- ),
- 'token' => array(
+ ],
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+ ],
+ 'token' => [
ApiBase::PARAM_DEPRECATED => true,
ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
ApiBase::PARAM_ISMULTI => true
- ),
- 'show' => array(
+ ],
+ 'show' => [
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'minor',
'!minor',
'bot',
'patrolled',
'!patrolled',
'unpatrolled'
- )
- ),
- 'limit' => array(
+ ]
+ ],
+ 'limit' => [
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
- ),
- 'type' => array(
+ ],
+ 'type' => [
ApiBase::PARAM_DFLT => 'edit|new|log|categorize',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
- ),
+ ],
'toponly' => false,
- 'continue' => array(
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
+ ],
'generaterevisions' => false,
- );
+ ];
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&list=recentchanges'
=> 'apihelp-query+recentchanges-example-simple',
'action=query&generator=recentchanges&grcshow=!patrolled&prop=info'
=> 'apihelp-query+recentchanges-example-generator',
- );
+ ];
}
public function getHelpUrls() {