From: Sam Reed Date: Mon, 21 Mar 2011 23:51:26 +0000 (+0000) Subject: * (bug 27589) list=allimages&aiprop=archivename is useless X-Git-Tag: 1.31.0-rc.0~31259 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=9818053bd3d9bcb2cbacfa8e6b4d7adbc37f9f26;p=lhc%2Fweb%2Fwiklou.git * (bug 27589) list=allimages&aiprop=archivename is useless Followup r84433 Add way to filter returned properties/descriptions --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e1f89d3c03..2886e8cf79 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -276,6 +276,7 @@ PHP if you have not done so prior to upgrading MediaWiki. the general site info results * (bug 16288) API: consider making closure status of wikis more clear with meta=siteinfo +* (bug 27589) list=allimages&aiprop=archivename is useless === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryAllimages.php b/includes/api/ApiQueryAllimages.php index 61adc32bab..f5ee4b4362 100644 --- a/includes/api/ApiQueryAllimages.php +++ b/includes/api/ApiQueryAllimages.php @@ -203,7 +203,7 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { 'sha1' => null, 'sha1base36' => null, 'prop' => array( - ApiBase::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames(), + ApiBase::PARAM_TYPE => ApiQueryImageInfo::getPropertyNames( $this->propertyFilter ), ApiBase::PARAM_DFLT => 'timestamp|url', ApiBase::PARAM_ISMULTI => true ), @@ -222,11 +222,13 @@ class ApiQueryAllimages extends ApiQueryGeneratorBase { 'limit' => 'How many images in total to return', 'sha1' => "SHA1 hash of image. Overrides {$this->getModulePrefix()}sha1base36", 'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki)', - 'prop' => ApiQueryImageInfo::getPropertyDescriptions(), + 'prop' => ApiQueryImageInfo::getPropertyDescriptions( $this->propertyFilter ), 'mime' => 'What MIME type to search for. e.g. image/jpeg. Disabled in Miser Mode', ); } + private $propertyFilter = array( 'archivename' ); + public function getDescription() { return 'Enumerate all images sequentially'; } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index a3e4c95373..5321a430c3 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -471,15 +471,18 @@ class ApiQueryImageInfo extends ApiQueryBase { /** * Returns all possible parameters to iiprop + * + * @param array $filter List of properties to filter out + * * @static * @return Array */ - public static function getPropertyNames() { - return array_keys( self::getProperties() ); + public static function getPropertyNames( $filter = array() ) { + return array_diff( array_keys( self::getProperties() ), $filter ); } /** - * Returns array key value pairs of + * Returns array key value pairs of properties and their descriptions * * @static * @return array @@ -506,14 +509,16 @@ class ApiQueryImageInfo extends ApiQueryBase { /** * Returns the descriptions for the properties provided by getPropertyNames() + * + * @param array $filter List of properties to filter out * * @static * @return array */ - public static function getPropertyDescriptions() { + public static function getPropertyDescriptions( $filter = array() ) { return array_merge( array( 'What image information to get:' ), - array_values( self::getProperties() ) + array_values( array_diff_key( self::getProperties(), array_flip( $filter ) ) ) ); }