Add extmetadata to the ForeignAPIFile iiprops
authorMark Holmquist <mtraceur@member.fsf.org>
Wed, 9 Oct 2013 22:14:52 +0000 (15:14 -0700)
committertgr <tgr.huwiki@gmail.com>
Tue, 29 Oct 2013 17:48:17 +0000 (17:48 +0000)
Also clean up iiprop handling in ForeignAPIRepo.

Change-Id: I4a1b46669658cc7b7d074f8fb85dd172e6c45633

includes/filerepo/ForeignAPIRepo.php [changed mode: 0644->0755]
includes/filerepo/file/ForeignAPIFile.php

old mode 100644 (file)
new mode 100755 (executable)
index 5eec9a5..07cc03b
@@ -42,6 +42,16 @@ class ForeignAPIRepo extends FileRepo {
         * Update the version every time you make breaking or significant changes. */
        const VERSION = "2.1";
 
+       /**
+        * List of iiprop values for the thumbnail fetch queries.
+        * @since 1.23
+        */
+       protected static $imageInfoProps = array(
+               'url',
+               'thumbnail',
+               'timestamp',
+       );
+
        var $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
        /* Check back with Commons after a day */
        var $apiThumbCacheExpiry = 86400; /* 24*60*60 */
@@ -238,7 +248,7 @@ class ForeignAPIRepo extends FileRepo {
        function getThumbUrl( $name, $width = -1, $height = -1, &$result = null, $otherParams = '' ) {
                $data = $this->fetchImageQuery( array(
                        'titles' => 'File:' . $name,
-                       'iiprop' => 'url|timestamp',
+                       'iiprop' => self::getIIProps(),
                        'iiurlwidth' => $width,
                        'iiurlheight' => $height,
                        'iiurlparam' => $otherParams,
@@ -265,7 +275,7 @@ class ForeignAPIRepo extends FileRepo {
        function getThumbError( $name, $width = -1, $height = -1, $otherParams = '', $lang = null ) {
                $data = $this->fetchImageQuery( array(
                        'titles' => 'File:' . $name,
-                       'iiprop' => 'url|timestamp',
+                       'iiprop' => self::getIIProps(),
                        'iiurlwidth' => $width,
                        'iiurlheight' => $height,
                        'iiurlparam' => $otherParams,
@@ -485,6 +495,14 @@ class ForeignAPIRepo extends FileRepo {
                }
        }
 
+       /**
+        * @return string
+        * @since 1.23
+        */
+       protected static function getIIProps() {
+               return join( '|', self::$imageInfoProps );
+       }
+
        /**
         * HTTP GET request to a mediawiki API (with caching)
         * @param $target string Used in cache key creation, mostly
index a1a6f26..fc9e176 100755 (executable)
@@ -86,7 +86,7 @@ class ForeignAPIFile extends File {
         * @return string
         */
        static function getProps() {
-               return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype';
+               return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
        }
 
        // Dummy functions...