* (bug 27589) list=allimages&aiprop=archivename is useless
authorSam Reed <reedy@users.mediawiki.org>
Mon, 21 Mar 2011 23:51:26 +0000 (23:51 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 21 Mar 2011 23:51:26 +0000 (23:51 +0000)
Followup r84433

Add way to filter returned properties/descriptions

RELEASE-NOTES
includes/api/ApiQueryAllimages.php
includes/api/ApiQueryImageInfo.php

index e1f89d3..2886e8c 100644 (file)
@@ -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 ===
 
index 61adc32..f5ee4b4 100644 (file)
@@ -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';
        }
index a3e4c95..5321a43 100644 (file)
@@ -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 ) ) )
                );
        }