From f507219e11b003d7f8f2bba169c27d0588d64f3a Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 13 Mar 2011 22:23:57 +0000 Subject: [PATCH] --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllimages.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index dfa6e38de2..66fe1fb2e7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -255,6 +255,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 26630) Add api for Special:ActiveUsers * (bug 27020) API: Allow title prefix search of logevents (only when not in miser mode) +* (bug 26629) add Special:MIMESearch to api === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index 89cc9db829..c23a8a6c36 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -117,6 +117,18 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { $this->addWhere( 'img_sha1=' . $db->addQuotes( $sha1 ) ); } + if ( !is_null( $params['mime'] ) ) { + global $wgMiserMode; + if ( $wgMiserMode ) { + $this->dieUsage( 'MIME search disabled in Miser Mode', 'mimeearchdisabled' ); + } + + list( $major, $minor ) = File::splitMime( $params['mime'] ); + + $this->addWhereFld( 'img_major_mime', $major ); + $this->addWhereFld( 'img_minor_mime', $minor ); + } + $this->addTables( 'image' ); $prop = array_flip( $params['prop'] ); @@ -194,7 +206,8 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { ApiBase::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames(), ApiBase::PARAM_DFLT => 'timestamp|url', ApiBase::PARAM_ISMULTI => true - ) + ), + 'mime' => null, ); } @@ -210,6 +223,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { 'sha1' => "SHA1 hash of image. Overrides {$this->getModulePrefix()}sha1base36", 'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki)', 'prop' => ApiQueryImageInfo::getPropertyDescriptions(), + 'mime' => 'What MIME type to search for. e.g. image/jpeg. Disabled in Miser Mode', ); } @@ -221,6 +235,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'params', 'info' => 'Use "gaifilterredir=nonredirects" option instead of "redirects" when using allimages as a generator' ), array( 'code' => 'unsupportedrepo', 'info' => 'Local file repository does not support querying all images' ), + array( 'code' => 'mimeearchdisabled', 'info' => 'MIME search disabled in Miser Mode' ), ) ); } -- 2.20.1