$this->multiUserMode = true;
$this->userprefix = $this->params['userprefix'];
} else {
- $this->usernames = array();
+ $this->usernames = [];
if ( !is_array( $this->params['user'] ) ) {
- $this->params['user'] = array( $this->params['user'] );
+ $this->params['user'] = [ $this->params['user'] ];
}
if ( !count( $this->params['user'] ) ) {
$this->dieUsage( 'User parameter may not be empty.', 'param_user' );
$res = $this->select( __METHOD__ );
if ( $this->fld_sizediff ) {
- $revIds = array();
+ $revIds = [];
foreach ( $res as $row ) {
if ( $row->rev_parent_id ) {
$revIds[] = $row->rev_parent_id;
}
$vals = $this->extractRowInfo( $row );
- $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
+ $fit = $this->getResult()->addValue( [ 'query', $this->getModuleName() ], null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
break;
}
$this->getResult()->addIndexedTagName(
- array( 'query', $this->getModuleName() ),
+ [ 'query', $this->getModuleName() ],
'item'
);
}
// row for anything we retrieve. We may also need the
// recentchanges row and/or tag summary row.
$user = $this->getUser();
- $tables = array( 'page', 'revision' ); // Order may change
+ $tables = [ 'page', 'revision' ]; // Order may change
$this->addWhere( 'page_id=rev_page' );
// Handle continue parameter
$show = $this->params['show'];
if ( $this->params['toponly'] ) { // deprecated/old param
- $this->logFeatureUsage( 'list=usercontribs&uctoponly' );
$show[] = 'top';
}
if ( !is_null( $show ) ) {
$this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
}
$this->addOption( 'LIMIT', $this->params['limit'] + 1 );
- $index = array( 'revision' => 'usertext_timestamp' );
+ $index = [ 'revision' => 'usertext_timestamp' ];
// Mandatory fields: timestamp allows request continuation
// ns+title checks if the user has access rights for this page
// user_text is necessary if multiple users were specified
- $this->addFields( array(
+ $this->addFields( [
'rev_id',
'rev_timestamp',
'page_namespace',
'rev_user',
'rev_user_text',
'rev_deleted'
- ) );
+ ] );
if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
$this->fld_patrolled
if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
// Put the tables in the right order for
// STRAIGHT_JOIN
- $tables = array( 'revision', 'recentchanges', 'page' );
+ $tables = [ 'revision', 'recentchanges', 'page' ];
$this->addOption( 'STRAIGHT_JOIN' );
$this->addWhere( 'rc_user_text=rev_user_text' );
$this->addWhere( 'rc_timestamp=rev_timestamp' );
$this->addWhere( 'rc_this_oldid=rev_id' );
} else {
$tables[] = 'recentchanges';
- $this->addJoinConds( array( 'recentchanges' => array(
- 'LEFT JOIN', array(
+ $this->addJoinConds( [ 'recentchanges' => [
+ 'LEFT JOIN', [
'rc_user_text=rev_user_text',
'rc_timestamp=rev_timestamp',
- 'rc_this_oldid=rev_id' ) ) ) );
+ 'rc_this_oldid=rev_id' ] ] ] );
}
}
if ( $this->fld_tags ) {
$this->addTables( 'tag_summary' );
$this->addJoinConds(
- array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) )
+ [ 'tag_summary' => [ 'LEFT JOIN', [ 'rev_id=ts_rev_id' ] ] ]
);
$this->addFields( 'ts_tags' );
}
if ( isset( $this->params['tag'] ) ) {
$this->addTables( 'change_tag' );
$this->addJoinConds(
- array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) )
+ [ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
);
$this->addWhereFld( 'ct_tag', $this->params['tag'] );
}
* @return array
*/
private function extractRowInfo( $row ) {
- $vals = array();
+ $vals = [];
$anyHidden = false;
if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
ApiResult::setIndexedTagName( $tags, 'tag' );
$vals['tags'] = $tags;
} else {
- $vals['tags'] = array();
+ $vals['tags'] = [];
}
}
}
public function getAllowedParams() {
- return array(
- 'limit' => array(
+ return [
+ '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
- ),
- 'start' => array(
+ ],
+ 'start' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'end' => array(
+ ],
+ 'end' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'continue' => array(
+ ],
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- 'user' => array(
+ ],
+ 'user' => [
+ ApiBase::PARAM_TYPE => 'user',
ApiBase::PARAM_ISMULTI => true
- ),
+ ],
'userprefix' => null,
- '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'
- ),
- 'prop' => array(
+ ],
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'ids|title|timestamp|comment|size|flags',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'ids',
'title',
'timestamp',
'flags',
'patrolled',
'tags'
- ),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
- ),
- 'show' => array(
+ ],
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+ ],
+ 'show' => [
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'minor',
'!minor',
'patrolled',
'!top',
'new',
'!new',
- ),
- ApiBase::PARAM_HELP_MSG => array(
+ ],
+ ApiBase::PARAM_HELP_MSG => [
'apihelp-query+usercontribs-param-show',
$this->getConfig()->get( 'RCMaxAge' )
- ),
- ),
+ ],
+ ],
'tag' => null,
- 'toponly' => array(
+ 'toponly' => [
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_DEPRECATED => true,
- ),
- );
+ ],
+ ];
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&list=usercontribs&ucuser=Example'
=> 'apihelp-query+usercontribs-example-user',
'action=query&list=usercontribs&ucuserprefix=192.0.2.'
=> 'apihelp-query+usercontribs-example-ipprefix',
- );
+ ];
}
public function getHelpUrls() {