* which may not necessarily be the same as the local DB.
*
* TODO: allow querying non-local repos.
- * @return DatabaseBase
+ * @return IDatabase
*/
protected function getDB() {
- return $this->mRepo->getSlaveDB();
+ return $this->mRepo->getReplicaDB();
}
public function execute() {
if ( $params['sort'] == 'name' ) {
// Check mutually exclusive params
- $disallowed = array( 'start', 'end', 'user' );
+ $disallowed = [ 'start', 'end', 'user' ];
foreach ( $disallowed as $pname ) {
if ( isset( $params[$pname] ) ) {
$this->dieUsage(
}
} else {
// Check mutually exclusive params
- $disallowed = array( 'from', 'to', 'prefix' );
+ $disallowed = [ 'from', 'to', 'prefix' ];
foreach ( $disallowed as $pname ) {
if ( isset( $params[$pname] ) ) {
$this->dieUsage(
}
if ( $params['filterbots'] != 'all' ) {
$this->addTables( 'user_groups' );
- $this->addJoinConds( array( 'user_groups' => array(
+ $this->addJoinConds( [ 'user_groups' => [
'LEFT JOIN',
- array(
+ [
'ug_group' => User::getGroupsWithPermission( 'bot' ),
'ug_user = img_user'
- )
- ) ) );
+ ]
+ ] ] );
$groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL' );
$this->addWhere( "ug_group IS $groupCond" );
}
$this->dieUsage( 'MIME search disabled in Miser Mode', 'mimesearchdisabled' );
}
- $mimeConds = array();
+ $mimeConds = [];
foreach ( $params['mime'] as $mime ) {
list( $major, $minor ) = File::splitMime( $mime );
$mimeConds[] = $db->makeList(
- array(
+ [
'img_major_mime' => $major,
'img_minor_mime' => $minor,
- ),
+ ],
LIST_AND
);
}
$this->addWhere( $db->makeList( $mimeConds, LIST_OR ) );
} else {
// no MIME types, no files
- $this->getResult()->addValue( 'query', $this->getModuleName(), array() );
+ $this->getResult()->addValue( 'query', $this->getModuleName(), [] );
return;
}
}
if ( $params['sort'] == 'timestamp' ) {
$this->addOption( 'ORDER BY', 'img_timestamp' . $sortFlag );
if ( !is_null( $params['user'] ) ) {
- $this->addOption( 'USE INDEX', array( 'image' => 'img_usertext_timestamp' ) );
+ $this->addOption( 'USE INDEX', [ 'image' => 'img_usertext_timestamp' ] );
} else {
- $this->addOption( 'USE INDEX', array( 'image' => 'img_timestamp' ) );
+ $this->addOption( 'USE INDEX', [ 'image' => 'img_timestamp' ] );
}
} else {
$this->addOption( 'ORDER BY', 'img_name' . $sortFlag );
$res = $this->select( __METHOD__ );
- $titles = array();
+ $titles = [];
$count = 0;
$result = $this->getResult();
foreach ( $res as $row ) {
if ( is_null( $resultPageSet ) ) {
$file = $repo->newFileFromRow( $row );
- $info = array_merge( array( 'name' => $row->img_name ),
+ $info = array_merge( [ 'name' => $row->img_name ],
ApiQueryImageInfo::getInfo( $file, $prop, $result ) );
self::addTitleInfo( $info, $file->getTitle() );
- $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $info );
+ $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $info );
if ( !$fit ) {
if ( $params['sort'] == 'name' ) {
$this->setContinueEnumParameter( 'continue', $row->img_name );
}
if ( is_null( $resultPageSet ) ) {
- $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'img' );
+ $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'img' );
} else {
$resultPageSet->populateFromTitles( $titles );
}
}
public function getAllowedParams() {
- $ret = array(
- 'sort' => array(
+ $ret = [
+ 'sort' => [
ApiBase::PARAM_DFLT => 'name',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'name',
'timestamp'
- )
- ),
- 'dir' => array(
+ ]
+ ],
+ 'dir' => [
ApiBase::PARAM_DFLT => 'ascending',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
// sort=name
'ascending',
'descending',
// sort=timestamp
'newer',
'older'
- )
- ),
+ ]
+ ],
'from' => null,
'to' => null,
- 'continue' => array(
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- 'start' => array(
+ ],
+ 'start' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'end' => array(
+ ],
+ 'end' => [
ApiBase::PARAM_TYPE => 'timestamp'
- ),
- 'prop' => array(
+ ],
+ 'prop' => [
ApiBase::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames( $this->propertyFilter ),
ApiBase::PARAM_DFLT => 'timestamp|url',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_HELP_MSG => 'apihelp-query+imageinfo-param-prop',
ApiBase::PARAM_HELP_MSG_PER_VALUE =>
ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ),
- ),
+ ],
'prefix' => null,
- 'minsize' => array(
+ 'minsize' => [
ApiBase::PARAM_TYPE => 'integer',
- ),
- 'maxsize' => array(
+ ],
+ 'maxsize' => [
ApiBase::PARAM_TYPE => 'integer',
- ),
+ ],
'sha1' => null,
'sha1base36' => null,
- 'user' => array(
+ 'user' => [
ApiBase::PARAM_TYPE => 'user'
- ),
- 'filterbots' => array(
+ ],
+ 'filterbots' => [
ApiBase::PARAM_DFLT => 'all',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'all',
'bots',
'nobots'
- )
- ),
- 'mime' => array(
+ ]
+ ],
+ 'mime' => [
ApiBase::PARAM_ISMULTI => true,
- ),
- '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
- ),
- );
+ ],
+ ];
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$ret['mime'][ApiBase::PARAM_HELP_MSG] = 'api-help-param-disabled-in-miser-mode';
return $ret;
}
- private $propertyFilter = array( 'archivename', 'thumbmime', 'uploadwarning' );
+ private $propertyFilter = [ 'archivename', 'thumbmime', 'uploadwarning' ];
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&list=allimages&aifrom=B'
=> 'apihelp-query+allimages-example-B',
'action=query&list=allimages&aiprop=user|timestamp|url&' .
'action=query&generator=allimages&gailimit=4&' .
'gaifrom=T&prop=imageinfo'
=> 'apihelp-query+allimages-example-generator',
- );
+ ];
}
public function getHelpUrls() {