jenkins-bot has submitted this change and it was merged.
Change subject: Allow querying for multiple MIME types in the allimages API
......................................................................
Allow querying for multiple MIME types in the allimages API
The 'aimime' parameter can now be a pipe-separated list of
MIME types. Also tweaked the English apihelp and added an
example for the new functionality.
Bug: T78690
Change-Id: I775ecae53c81eccb0a898081715d48589b53af15
---
M RELEASE-NOTES-1.25
M includes/api/ApiQueryAllImages.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
4 files changed, 27 insertions(+), 5 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 77dc55b..065a5d7 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -161,6 +161,8 @@
* (T76052) list=tags can now indicate whether a tag is defined.
* (T75522) list=prefixsearch now supports continuation
* (T78737) action=expandtemplates can now return page properties.
+* (T78690) list=allimages now accepts multiple pipe-separated values
+ for the 'aimime' parameter.
=== Action API internal changes in 1.25 ===
* ApiHelp has been rewritten to support i18n and paginated HTML output.
diff --git a/includes/api/ApiQueryAllImages.php
b/includes/api/ApiQueryAllImages.php
index 20e9f5e..6c962cd 100644
--- a/includes/api/ApiQueryAllImages.php
+++ b/includes/api/ApiQueryAllImages.php
@@ -232,10 +232,25 @@
$this->dieUsage( 'MIME search disabled in Miser
Mode', 'mimesearchdisabled' );
}
- list( $major, $minor ) = File::splitMime(
$params['mime'] );
-
- $this->addWhereFld( 'img_major_mime', $major );
- $this->addWhereFld( 'img_minor_mime', $minor );
+ $mimeConds = array();
+ 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
+ );
+ }
+ // safeguard against internal_api_error_DBQueryError
+ if ( count( $mimeConds ) > 0 ) {
+ $this->addWhere( $db->makeList( $mimeConds,
LIST_OR ) );
+ } else {
+ // no MIME types, no files
+ $this->getResult()->addValue( 'query',
$this->getModuleName(), array() );
+ return;
+ }
}
$limit = $params['limit'];
@@ -359,6 +374,7 @@
),
'mime' => array(
ApiBase::PARAM_DFLT => null,
+ ApiBase::PARAM_ISMULTI => true,
),
'limit' => array(
ApiBase::PARAM_DFLT => 10,
@@ -385,6 +401,8 @@
'action=query&list=allimages&aiprop=user|timestamp|url&' .
'aisort=timestamp&aidir=older'
=> 'apihelp-query+allimages-example-recent',
+ 'action=query&list=allimages&aimime=image/png|image/gif'
+ => 'apihelp-query+allimages-example-mimetypes',
'action=query&generator=allimages&gailimit=4&' .
'gaifrom=T&prop=imageinfo'
=> 'apihelp-query+allimages-example-generator',
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index 61de86c..9286424 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -365,10 +365,11 @@
"apihelp-query+allimages-param-sha1base36": "SHA1 hash of image in base
36 (used in MediaWiki).",
"apihelp-query+allimages-param-user": "Only return files uploaded by
this user. Can only be used with $1sort=timestamp. Cannot be used together with
$1filterbots.",
"apihelp-query+allimages-param-filterbots": "How to filter files
uploaded by bots. Can only be used with $1sort=timestamp. Cannot be used
together with $1user.",
- "apihelp-query+allimages-param-mime": "What MIME type to search for.
e.g. image/jpeg.",
+ "apihelp-query+allimages-param-mime": "What MIME types to search for,
e.g. <kbd>image/jpeg</kbd>.",
"apihelp-query+allimages-param-limit": "How many images in total to
return.",
"apihelp-query+allimages-example-B": "Show a list of files starting at
the letter \"B\"",
"apihelp-query+allimages-example-recent": "Show a list of recently
uploaded files similar to [[Special:NewFiles]]",
+ "apihelp-query+allimages-example-mimetypes": "Show a list of files with
MIME type <kbd>image/png</kbd> or <kbd>image/gif</kbd>",
"apihelp-query+allimages-example-generator": "Show info about 4 files
starting at the letter \"T\"",
"apihelp-query+alllinks-description": "Enumerate all links that point
to a given namespace.",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index c2696d1..19ec6cb 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -339,6 +339,7 @@
"apihelp-query+allimages-param-limit":
"{{doc-apihelp-param|query+allimages|limit}}",
"apihelp-query+allimages-example-B":
"{{doc-apihelp-example|query+allimages}}",
"apihelp-query+allimages-example-recent":
"{{doc-apihelp-example|query+allimages}}",
+ "apihelp-query+allimages-example-mimetypes":
"{{doc-apihelp-example|query+allimages}}",
"apihelp-query+allimages-example-generator":
"{{doc-apihelp-example|query+allimages}}",
"apihelp-query+alllinks-description":
"{{doc-apihelp-description|query+alllinks}}",
"apihelp-query+alllinks-param-from":
"{{doc-apihelp-param|query+alllinks|from}}",
--
To view, visit https://gerrit.wikimedia.org/r/182062
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I775ecae53c81eccb0a898081715d48589b53af15
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits