48 private $groupPermissionsLookup;
62 parent::__construct( $query, $moduleName,
'ai' );
64 $this->groupPermissionsLookup = $groupPermissionsLookup;
75 return $this->mRepo->getReplicaDB();
91 if ( $resultPageSet->isResolvingRedirects() ) {
92 $this->
dieWithError(
'apierror-allimages-redirect',
'invalidparammix' );
95 $this->run( $resultPageSet );
102 private function run( $resultPageSet =
null ) {
110 $db = $this->
getDB();
115 $prop = array_fill_keys( $params[
'prop'],
true );
118 $this->
addTables( $fileQuery[
'tables'] );
119 $this->
addFields( $fileQuery[
'fields'] );
122 $ascendingOrder =
true;
123 if ( $params[
'dir'] ==
'descending' || $params[
'dir'] ==
'older' ) {
124 $ascendingOrder =
false;
127 if ( $params[
'sort'] ==
'name' ) {
129 $disallowed = [
'start',
'end',
'user' ];
130 foreach ( $disallowed as $pname ) {
131 if ( isset( $params[$pname] ) ) {
134 'apierror-invalidparammix-mustusewith',
136 "{$prefix}sort=timestamp"
142 if ( $params[
'filterbots'] !=
'all' ) {
145 'apierror-invalidparammix-mustusewith',
146 "{$prefix}filterbots",
147 "{$prefix}sort=timestamp"
154 if ( $params[
'continue'] !==
null ) {
156 $op = $ascendingOrder ?
'>=' :
'<=';
157 $this->
addWhere( $db->buildComparison( $op, [
'img_name' => $cont[0] ] ) );
163 $this->
addWhereRange(
'img_name', $ascendingOrder ?
'newer' :
'older', $from, $to );
165 if ( isset( $params[
'prefix'] ) ) {
166 $this->
addWhere(
'img_name' . $db->buildLike(
167 $this->titlePartToKey( $params[
'prefix'],
NS_FILE ),
168 $db->anyString() ) );
172 $disallowed = [
'from',
'to',
'prefix' ];
173 foreach ( $disallowed as $pname ) {
174 if ( isset( $params[$pname] ) ) {
177 'apierror-invalidparammix-mustusewith',
185 if ( $params[
'user'] !==
null && $params[
'filterbots'] !=
'all' ) {
189 [
'apierror-invalidparammix-cannotusewith',
"{$prefix}user",
"{$prefix}filterbots" ]
196 $ascendingOrder ?
'newer' :
'older',
201 $this->
addWhereRange(
'img_name', $ascendingOrder ?
'newer' :
'older', null, null );
203 if ( $params[
'continue'] !==
null ) {
205 $op = ( $ascendingOrder ?
'>=' :
'<=' );
206 $this->
addWhere( $db->buildComparison( $op, [
207 'img_timestamp' => $db->timestamp( $cont[0] ),
208 'img_name' => $cont[1],
213 if ( $params[
'user'] !==
null ) {
214 $this->
addWhereFld( $fileQuery[
'fields'][
'img_user_text'], $params[
'user'] );
216 if ( $params[
'filterbots'] !=
'all' ) {
221 'ug_group' => $this->groupPermissionsLookup->getGroupsWithPermission(
'bot' ),
222 'ug_user = actor_user',
223 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
226 $groupCond = $params[
'filterbots'] ==
'nobots' ?
'NULL' :
'NOT NULL';
227 $this->
addWhere(
"ug_group IS $groupCond" );
232 if ( isset( $params[
'minsize'] ) ) {
233 $this->
addWhere(
'img_size>=' . (
int)$params[
'minsize'] );
236 if ( isset( $params[
'maxsize'] ) ) {
237 $this->
addWhere(
'img_size<=' . (
int)$params[
'maxsize'] );
241 if ( isset( $params[
'sha1'] ) ) {
242 $sha1 = strtolower( $params[
'sha1'] );
246 $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 );
247 } elseif ( isset( $params[
'sha1base36'] ) ) {
248 $sha1 = strtolower( $params[
'sha1base36'] );
250 $this->
dieWithError(
'apierror-invalidsha1base36hash' );
257 if ( $params[
'mime'] !==
null ) {
258 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
263 foreach ( $params[
'mime'] as
$mime ) {
265 $mimeConds[] = $db->makeList(
267 'img_major_mime' => $major,
268 'img_minor_mime' => $minor,
274 if ( count( $mimeConds ) > 0 ) {
283 $limit = $params[
'limit'];
291 foreach (
$res as $row ) {
292 if ( ++$count > $limit ) {
295 if ( $params[
'sort'] ==
'name' ) {
303 if ( $resultPageSet ===
null ) {
304 $file = $repo->newFileFromRow( $row );
305 $info = array_merge( [
'name' => $row->img_name ],
309 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $info );
311 if ( $params[
'sort'] ==
'name' ) {
319 $titles[] = Title::makeTitle(
NS_FILE, $row->img_name );
323 if ( $resultPageSet ===
null ) {
324 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'img' );
326 $resultPageSet->populateFromTitles( $titles );
333 ParamValidator::PARAM_DEFAULT =>
'name',
334 ParamValidator::PARAM_TYPE => [
340 ParamValidator::PARAM_DEFAULT =>
'ascending',
341 ParamValidator::PARAM_TYPE => [
356 ParamValidator::PARAM_TYPE =>
'timestamp'
359 ParamValidator::PARAM_TYPE =>
'timestamp'
363 ParamValidator::PARAM_DEFAULT =>
'timestamp|url',
364 ParamValidator::PARAM_ISMULTI =>
true,
371 ParamValidator::PARAM_TYPE =>
'integer',
374 ParamValidator::PARAM_TYPE =>
'integer',
377 'sha1base36' =>
null,
379 ParamValidator::PARAM_TYPE =>
'user',
380 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'id',
'interwiki' ],
383 ParamValidator::PARAM_DEFAULT =>
'all',
384 ParamValidator::PARAM_TYPE => [
391 ParamValidator::PARAM_ISMULTI =>
true,
394 ParamValidator::PARAM_DEFAULT => 10,
395 ParamValidator::PARAM_TYPE =>
'limit',
396 IntegerDef::PARAM_MIN => 1,
402 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
409 private $propertyFilter = [
'archivename',
'thumbmime',
'uploadwarning' ];
413 'action=query&list=allimages&aifrom=B'
414 =>
'apihelp-query+allimages-example-b',
415 'action=query&list=allimages&aiprop=user|timestamp|url&' .
416 'aisort=timestamp&aidir=older'
417 =>
'apihelp-query+allimages-example-recent',
418 'action=query&list=allimages&aimime=image/png|image/gif'
419 =>
'apihelp-query+allimages-example-mimetypes',
420 'action=query&generator=allimages&gailimit=4&' .
421 'gaifrom=T&prop=imageinfo'
422 =>
'apihelp-query+allimages-example-generator',
427 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allimages';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
Query module to enumerate all images.
getExamplesMessages()
Returns usage examples for this module.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getDB()
Override parent method to make sure the repo's DB is used which may not necessarily be the same as th...
executeGenerator( $resultPageSet)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName, RepoGroup $repoGroup, GroupPermissionsLookup $groupPermissionsLookup)
getHelpUrls()
Return links to more detailed help pages about the module.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
validateSha1Base36Hash( $hash)
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
titlePartToKey( $titlePart, $namespace=NS_MAIN)
Convert an input title or title prefix into a dbkey.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
static getPropertyNames( $filter=[])
Returns all possible parameters to iiprop.
static getInfo( $file, $prop, $result, $thumbParams=null, $opts=false)
Get result information for an image revision.
static getPropertyMessages( $filter=[])
Returns messages for all possible parameters to iiprop.
This is the main query class.
static splitMime(?string $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
static getQueryInfo(array $options=[])
Return the tables, fields, and join conditions to be selected to create a new localfile object.
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
A class containing constants representing the names of configuration variables.
Prioritized list of file repositories.
getLocalRepo()
Get the local repository, i.e.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.