64 parent::__construct( $query, $moduleName,
'ai' );
66 $this->groupPermissionsLookup = $groupPermissionsLookup;
77 return $this->mRepo->getReplicaDB();
93 if ( $resultPageSet->isResolvingRedirects() ) {
94 $this->
dieWithError(
'apierror-allimages-redirect',
'invalidparammix' );
97 $this->
run( $resultPageSet );
104 private function run( $resultPageSet =
null ) {
112 $db = $this->
getDB();
117 $prop = array_fill_keys(
$params[
'prop'],
true );
120 $this->
addTables( $fileQuery[
'tables'] );
121 $this->
addFields( $fileQuery[
'fields'] );
124 $ascendingOrder =
true;
125 if (
$params[
'dir'] ==
'descending' ||
$params[
'dir'] ==
'older' ) {
126 $ascendingOrder =
false;
129 if (
$params[
'sort'] ==
'name' ) {
131 $disallowed = [
'start',
'end',
'user' ];
132 foreach ( $disallowed as $pname ) {
133 if ( isset(
$params[$pname] ) ) {
136 'apierror-invalidparammix-mustusewith',
138 "{$prefix}sort=timestamp"
144 if (
$params[
'filterbots'] !=
'all' ) {
147 'apierror-invalidparammix-mustusewith',
148 "{$prefix}filterbots",
149 "{$prefix}sort=timestamp"
156 if (
$params[
'continue'] !==
null ) {
158 $op = $ascendingOrder ?
'>=' :
'<=';
159 $this->
addWhere( $db->expr(
'img_name', $op, $cont[0] ) );
165 $this->
addWhereRange(
'img_name', $ascendingOrder ?
'newer' :
'older', $from, $to );
167 if ( isset(
$params[
'prefix'] ) ) {
178 $disallowed = [
'from',
'to',
'prefix' ];
179 foreach ( $disallowed as $pname ) {
180 if ( isset(
$params[$pname] ) ) {
183 'apierror-invalidparammix-mustusewith',
191 if (
$params[
'user'] !==
null &&
$params[
'filterbots'] !=
'all' ) {
195 [
'apierror-invalidparammix-cannotusewith',
"{$prefix}user",
"{$prefix}filterbots" ]
202 $ascendingOrder ?
'newer' :
'older',
207 $this->
addWhereRange(
'img_name', $ascendingOrder ?
'newer' :
'older', null, null );
209 if (
$params[
'continue'] !==
null ) {
211 $op = ( $ascendingOrder ?
'>=' :
'<=' );
212 $this->
addWhere( $db->buildComparison( $op, [
213 'img_timestamp' => $db->timestamp( $cont[0] ),
214 'img_name' => $cont[1],
219 if (
$params[
'user'] !==
null ) {
222 if (
$params[
'filterbots'] !=
'all' ) {
227 'ug_group' => $this->groupPermissionsLookup->getGroupsWithPermission(
'bot' ),
228 'ug_user = actor_user',
229 $db->expr(
'ug_expiry',
'=',
null )->or(
'ug_expiry',
'>=', $db->timestamp() )
232 $groupCond =
$params[
'filterbots'] ==
'nobots' ?
'NULL' :
'NOT NULL';
233 $this->
addWhere(
"ug_group IS $groupCond" );
238 if ( isset(
$params[
'minsize'] ) ) {
242 if ( isset(
$params[
'maxsize'] ) ) {
247 if ( isset(
$params[
'sha1'] ) ) {
248 $sha1 = strtolower(
$params[
'sha1'] );
252 $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 );
253 } elseif ( isset(
$params[
'sha1base36'] ) ) {
254 $sha1 = strtolower(
$params[
'sha1base36'] );
256 $this->
dieWithError(
'apierror-invalidsha1base36hash' );
263 if (
$params[
'mime'] !==
null ) {
264 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
269 foreach (
$params[
'mime'] as $mime ) {
272 $db->expr(
'img_major_mime',
'=', $major )
273 ->and(
'img_minor_mime',
'=', $minor );
275 if ( count( $mimeConds ) > 0 ) {
287 $res = $this->
select( __METHOD__ );
292 foreach ( $res as $row ) {
293 if ( ++$count > $limit ) {
296 if (
$params[
'sort'] ==
'name' ) {
304 if ( $resultPageSet ===
null ) {
305 $file = $repo->newFileFromRow( $row );
306 $info = array_merge( [
'name' => $row->img_name ],
310 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $info );
312 if (
$params[
'sort'] ==
'name' ) {
320 $titles[] = Title::makeTitle(
NS_FILE, $row->img_name );
324 if ( $resultPageSet ===
null ) {
325 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'img' );
327 $resultPageSet->populateFromTitles( $titles );
334 ParamValidator::PARAM_DEFAULT =>
'name',
335 ParamValidator::PARAM_TYPE => [
341 ParamValidator::PARAM_DEFAULT =>
'ascending',
342 ParamValidator::PARAM_TYPE => [
357 ParamValidator::PARAM_TYPE =>
'timestamp'
360 ParamValidator::PARAM_TYPE =>
'timestamp'
364 ParamValidator::PARAM_DEFAULT =>
'timestamp|url',
365 ParamValidator::PARAM_ISMULTI =>
true,
372 ParamValidator::PARAM_TYPE =>
'integer',
375 ParamValidator::PARAM_TYPE =>
'integer',
378 'sha1base36' =>
null,
380 ParamValidator::PARAM_TYPE =>
'user',
381 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'temp',
'id',
'interwiki' ],
384 ParamValidator::PARAM_DEFAULT =>
'all',
385 ParamValidator::PARAM_TYPE => [
392 ParamValidator::PARAM_ISMULTI =>
true,
395 ParamValidator::PARAM_DEFAULT => 10,
396 ParamValidator::PARAM_TYPE =>
'limit',
397 IntegerDef::PARAM_MIN => 1,
403 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
410 private $propertyFilter = [
'archivename',
'thumbmime',
'uploadwarning' ];
414 'action=query&list=allimages&aifrom=B'
415 =>
'apihelp-query+allimages-example-b',
416 'action=query&list=allimages&aiprop=user|timestamp|url&' .
417 'aisort=timestamp&aidir=older'
418 =>
'apihelp-query+allimages-example-recent',
419 'action=query&list=allimages&aimime=image/png|image/gif'
420 =>
'apihelp-query+allimages-example-mimetypes',
421 'action=query&generator=allimages&gailimit=4&' .
422 'gaifrom=T&prop=imageinfo'
423 =>
'apihelp-query+allimages-example-generator',
428 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allimages';
array $params
The job parameters.
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.