private $dfltNamespace = NS_MAIN;
private $hasNamespace = true;
private $useIndex = null;
- private $props = array();
+ private $props = [];
public function __construct( ApiQuery $query, $moduleName ) {
switch ( $moduleName ) {
$this->table = 'redirect';
$this->tablePrefix = 'rd_';
$this->indexTag = 'r';
- $this->props = array(
+ $this->props = [
'fragment' => 'rd_fragment',
'interwiki' => 'rd_interwiki',
- );
+ ];
break;
default:
ApiBase::dieDebug( __METHOD__, 'Unknown module name' );
}
if ( $params['unique'] ) {
- $matches = array_intersect_key( $prop, $this->props + array( 'ids' => 1 ) );
+ $matches = array_intersect_key( $prop, $this->props + [ 'ids' => 1 ] );
if ( $matches ) {
$p = $this->getModulePrefix();
- $this->dieUsage(
- "Cannot use {$p}prop=" . join( '|', array_keys( $matches ) ) . " with {$p}unique",
- 'params'
+ $this->dieWithError(
+ [
+ 'apierror-invalidparammix-cannotusewith',
+ "{$p}prop=" . implode( '|', array_keys( $matches ) ),
+ "{$p}unique"
+ ],
+ 'invalidparammix'
);
}
$this->addOption( 'DISTINCT' );
$params['prefix'], $namespace ), $db->anyString() ) );
}
- $this->addFields( array( 'pl_title' => $pfx . $fieldTitle ) );
- $this->addFieldsIf( array( 'pl_from' => $pfx . 'from' ), !$params['unique'] );
+ $this->addFields( [ 'pl_title' => $pfx . $fieldTitle ] );
+ $this->addFieldsIf( [ 'pl_from' => $pfx . 'from' ], !$params['unique'] );
foreach ( $this->props as $name => $field ) {
$this->addFieldsIf( $field, isset( $prop[$name] ) );
}
$this->addOption( 'LIMIT', $limit + 1 );
$sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
- $orderBy = array();
+ $orderBy = [];
$orderBy[] = $pfx . $fieldTitle . $sort;
if ( !$params['unique'] ) {
$orderBy[] = $pfx . 'from' . $sort;
$res = $this->select( __METHOD__ );
- $pageids = array();
- $titles = array();
+ $pageids = [];
+ $titles = [];
$count = 0;
$result = $this->getResult();
foreach ( $res as $row ) {
}
if ( is_null( $resultPageSet ) ) {
- $vals = array(
+ $vals = [
ApiResult::META_TYPE => 'assoc',
- );
+ ];
if ( $fld_ids ) {
$vals['fromid'] = intval( $row->pl_from );
}
$vals[$name] = $row->$field;
}
}
- $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
if ( !$fit ) {
if ( $params['unique'] ) {
$this->setContinueEnumParameter( 'continue', $row->pl_title );
}
if ( is_null( $resultPageSet ) ) {
- $result->addIndexedTagName( array( 'query', $this->getModuleName() ), $this->indexTag );
+ $result->addIndexedTagName( [ 'query', $this->getModuleName() ], $this->indexTag );
} elseif ( $params['unique'] ) {
$resultPageSet->populateFromTitles( $titles );
} else {
}
public function getAllowedParams() {
- $allowedParams = array(
- 'continue' => array(
+ $allowedParams = [
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
+ ],
'from' => null,
'to' => null,
'prefix' => null,
'unique' => false,
- 'prop' => array(
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'title',
ApiBase::PARAM_TYPE => array_merge(
- array( 'ids', 'title' ), array_keys( $this->props )
+ [ 'ids', 'title' ], array_keys( $this->props )
),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
- ),
- 'namespace' => array(
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+ ],
+ 'namespace' => [
ApiBase::PARAM_DFLT => $this->dfltNamespace,
- ApiBase::PARAM_TYPE => 'namespace'
- ),
- 'limit' => array(
+ ApiBase::PARAM_TYPE => 'namespace',
+ ApiBase::PARAM_EXTRA_NAMESPACES => [ NS_MEDIA, NS_SPECIAL ],
+ ],
+ '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
- ),
- 'dir' => array(
+ ],
+ 'dir' => [
ApiBase::PARAM_DFLT => 'ascending',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'ascending',
'descending'
- )
- ),
- );
+ ]
+ ],
+ ];
if ( !$this->hasNamespace ) {
unset( $allowedParams['namespace'] );
}
$name = $this->getModuleName();
$path = $this->getModulePath();
- return array(
+ return [
"action=query&list={$name}&{$p}from=B&{$p}prop=ids|title"
=> "apihelp-$path-example-B",
"action=query&list={$name}&{$p}unique=&{$p}from=B"
=> "apihelp-$path-example-unique-generator",
"action=query&generator={$name}&g{$p}from=B"
=> "apihelp-$path-example-generator",
- );
+ ];
}
public function getHelpUrls() {