Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignAPIFile.php
index 43cb5a5..43b6855 100644 (file)
  * @ingroup FileAbstraction
  */
 class ForeignAPIFile extends File {
+       /** @var bool */
        private $mExists;
+       /** @var array */
+       private $mInfo = [];
 
        protected $repoClass = 'ForeignApiRepo';
 
@@ -53,7 +56,7 @@ class ForeignAPIFile extends File {
         * @return ForeignAPIFile|null
         */
        static function newFromTitle( Title $title, $repo ) {
-               $data = $repo->fetchImageQuery( array(
+               $data = $repo->fetchImageQuery( [
                        'titles' => 'File:' . $title->getDBkey(),
                        'iiprop' => self::getProps(),
                        'prop' => 'imageinfo',
@@ -61,7 +64,7 @@ class ForeignAPIFile extends File {
                        // extmetadata is language-dependant, accessing the current language here
                        // would be problematic, so we just get them all
                        'iiextmetadatamultilang' => 1,
-               ) );
+               ] );
 
                $info = $repo->getImageInfo( $data );
 
@@ -196,7 +199,7 @@ class ForeignAPIFile extends File {
                if ( !is_array( $metadata ) ) {
                        return $metadata;
                }
-               $ret = array();
+               $ret = [];
                foreach ( $metadata as $meta ) {
                        $ret[$meta['name']] = self::parseMetadata( $meta['value'] );
                }
@@ -229,7 +232,7 @@ class ForeignAPIFile extends File {
                if ( isset( $this->mInfo['descriptionshorturl'] ) ) {
                        return $this->mInfo['descriptionshorturl'];
                } elseif ( isset( $this->mInfo['pageid'] ) ) {
-                       $url = $this->repo->makeUrl( array( 'curid' => $this->mInfo['pageid'] ) );
+                       $url = $this->repo->makeUrl( [ 'curid' => $this->mInfo['pageid'] ] );
                        if ( $url !== false ) {
                                return $url;
                        }
@@ -244,7 +247,7 @@ class ForeignAPIFile extends File {
        public function getUser( $type = 'text' ) {
                if ( $type == 'text' ) {
                        return isset( $this->mInfo['user'] ) ? strval( $this->mInfo['user'] ) : null;
-               } elseif ( $type == 'id' ) {
+               } else {
                        return 0; // What makes sense here, for a remote user?
                }
        }
@@ -334,9 +337,9 @@ class ForeignAPIFile extends File {
         */
        function getThumbnails() {
                $dir = $this->getThumbPath( $this->getName() );
-               $iter = $this->repo->getBackend()->getFileList( array( 'dir' => $dir ) );
+               $iter = $this->repo->getBackend()->getFileList( [ 'dir' => $dir ] );
 
-               $files = array();
+               $files = [];
                foreach ( $iter as $file ) {
                        $files[] = $file;
                }
@@ -344,10 +347,7 @@ class ForeignAPIFile extends File {
                return $files;
        }
 
-       /**
-        * @see File::purgeCache()
-        */
-       function purgeCache( $options = array() ) {
+       function purgeCache( $options = [] ) {
                $this->purgeThumbnails( $options );
                $this->purgeDescriptionPage();
        }
@@ -364,7 +364,7 @@ class ForeignAPIFile extends File {
        /**
         * @param array $options
         */
-       function purgeThumbnails( $options = array() ) {
+       function purgeThumbnails( $options = [] ) {
                $key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() );
                ObjectCache::getMainWANInstance()->delete( $key );
 
@@ -376,7 +376,7 @@ class ForeignAPIFile extends File {
                }
 
                $dir = $this->getThumbPath( $this->getName() );
-               $purgeList = array();
+               $purgeList = [];
                foreach ( $files as $file ) {
                        $purgeList[] = "{$dir}{$file}";
                }