Make mediawiki.special.pageLanguage work again
[lhc/web/wiklou.git] / includes / filerepo / ForeignAPIRepo.php
index 3747e60..a8d37a1 100644 (file)
@@ -55,11 +55,11 @@ class ForeignAPIRepo extends FileRepo {
        );
 
        protected $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
-       /** @var int Check back with Commons after a day (24*60*60) */
-       protected $apiThumbCacheExpiry = 86400;
+       /** @var int Check back with Commons after this expiry */
+       protected $apiThumbCacheExpiry = 86400; // 1 day (24*3600)
 
-       /** @var int Redownload thumbnail files after a month (86400*30) */
-       protected $fileCacheExpiry = 2592000;
+       /** @var int Redownload thumbnail files after this expiry */
+       protected $fileCacheExpiry = 2592000; // 1 month (30*24*3600)
 
        /** @var array */
        protected $mFileExists = array();
@@ -218,7 +218,11 @@ class ForeignAPIRepo extends FileRepo {
                if ( $data && isset( $data['query']['pages'] ) ) {
                        foreach ( $data['query']['pages'] as $info ) {
                                if ( isset( $info['imageinfo'][0] ) ) {
-                                       return $info['imageinfo'][0];
+                                       $return = $info['imageinfo'][0];
+                                       if ( isset( $info['pageid'] ) ) {
+                                               $return['pageid'] = $info['pageid'];
+                                       }
+                                       return $return;
                                }
                        }
                }
@@ -499,7 +503,7 @@ class ForeignAPIRepo extends FileRepo {
 
        /**
         * Like a Http:get request, but with custom User-Agent.
-        * @see Http:get
+        * @see Http::get
         * @param string $url
         * @param string $timeout
         * @param array $options
@@ -552,19 +556,16 @@ class ForeignAPIRepo extends FileRepo {
                }
 
                if ( !isset( $this->mQueryCache[$url] ) ) {
-                       global $wgMemc;
-
-                       $key = $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) );
-                       $data = $wgMemc->get( $key );
-
-                       if ( !$data ) {
-                               $data = self::httpGet( $url );
-
-                               if ( !$data ) {
-                                       return null;
+                       $data = ObjectCache::getMainWANInstance()->getWithSetCallback(
+                               $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) ),
+                               $cacheTTL,
+                               function () use ( $url ) {
+                                       return ForeignAPIRepo::httpGet( $url );
                                }
+                       );
 
-                               $wgMemc->set( $key, $data, $cacheTTL );
+                       if ( !$data ) {
+                               return null;
                        }
 
                        if ( count( $this->mQueryCache ) > 100 ) {