Fix property filter for ApiQueryStashImageInfo::getPropertyNames
authorUmherirrender <umherirrender_de.wp@web.de>
Thu, 9 May 2019 19:36:30 +0000 (21:36 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Tue, 10 Sep 2019 18:14:49 +0000 (18:14 +0000)
The property filter in ApiQueryStashImageInfo was only applied on calls
from the class itself. The call from UploadBase does not applied the
filter and than after successful upload of a stashed file the attributes
like user or mediatype are shown, but empty and not needed.

Change-Id: I89b2a935bacea81b4c8807d7ee77021377c8635c

includes/api/ApiQueryStashImageInfo.php

index 1924ca0..c84de8c 100644 (file)
@@ -70,11 +70,37 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                }
        }
 
-       private $propertyFilter = [
+       private static $propertyFilter = [
                'user', 'userid', 'comment', 'parsedcomment',
                'mediatype', 'archivename', 'uploadwarning',
        ];
 
+       /**
+        * Returns all possible parameters to siiprop
+        *
+        * @param array|null $filter List of properties to filter out
+        * @return array
+        */
+       public static function getPropertyNames( $filter = null ) {
+               if ( $filter === null ) {
+                       $filter = self::$propertyFilter;
+               }
+               return parent::getPropertyNames( $filter );
+       }
+
+       /**
+        * Returns messages for all possible parameters to siiprop
+        *
+        * @param array|null $filter List of properties to filter out
+        * @return array
+        */
+       public static function getPropertyMessages( $filter = null ) {
+               if ( $filter === null ) {
+                       $filter = self::$propertyFilter;
+               }
+               return parent::getPropertyMessages( $filter );
+       }
+
        public function getAllowedParams() {
                return [
                        'filekey' => [
@@ -87,9 +113,9 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                        'prop' => [
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_DFLT => 'timestamp|url',
-                               ApiBase::PARAM_TYPE => self::getPropertyNames( $this->propertyFilter ),
+                               ApiBase::PARAM_TYPE => self::getPropertyNames(),
                                ApiBase::PARAM_HELP_MSG => 'apihelp-query+imageinfo-param-prop',
-                               ApiBase::PARAM_HELP_MSG_PER_VALUE => self::getPropertyMessages( $this->propertyFilter )
+                               ApiBase::PARAM_HELP_MSG_PER_VALUE => self::getPropertyMessages()
                        ],
                        'urlwidth' => [
                                ApiBase::PARAM_TYPE => 'integer',