Ricordisamoa has uploaded a new change for review.
https://gerrit.wikimedia.org/r/182062
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, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/62/182062/1
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..1565bfa 100644
--- a/includes/api/ApiQueryAllImages.php
+++ b/includes/api/ApiQueryAllImages.php
@@ -232,10 +232,16 @@
$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
);
+ $conds = array(
+ 'img_major_mime = ' . $db->addQuotes(
$major ),
+ 'img_minor_mime = ' . $db->addQuotes(
$minor )
+ );
+ $mimeConds[] = '(' . implode( ' AND ', $conds )
. ')';
+ }
+ $this->addWhere( implode( ' OR ', $mimeConds ) );
}
$limit = $params['limit'];
@@ -359,6 +365,7 @@
),
'mime' => array(
ApiBase::PARAM_DFLT => null,
+ ApiBase::PARAM_ISMULTI => true,
),
'limit' => array(
ApiBase::PARAM_DFLT => 10,
@@ -385,6 +392,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..85ca389 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 type(s) to search for.
e.g. image/jpeg.",
"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 \"image/png\" or \"image/gif\"",
"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: newchange
Gerrit-Change-Id: I775ecae53c81eccb0a898081715d48589b53af15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits