Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignAPIFile.php
index f6752d8..8dcb289 100644 (file)
  * @ingroup FileAbstraction
  */
 class ForeignAPIFile extends File {
+       /** @var bool */
        private $mExists;
+       /** @var array */
+       private $mInfo = [];
 
-       protected $repoClass = 'ForeignApiRepo';
+       protected $repoClass = ForeignApiRepo::class;
 
        /**
         * @param Title|string|bool $title
@@ -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?
                }
        }
@@ -283,7 +286,7 @@ class ForeignAPIFile extends File {
         */
        function getMimeType() {
                if ( !isset( $this->mInfo['mime'] ) ) {
-                       $magic = MimeMagic::singleton();
+                       $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
                        $this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
                }
 
@@ -297,7 +300,7 @@ class ForeignAPIFile extends File {
                if ( isset( $this->mInfo['mediatype'] ) ) {
                        return $this->mInfo['mediatype'];
                }
-               $magic = MimeMagic::singleton();
+               $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
 
                return $magic->getMediaType( null, $this->getMimeType() );
        }
@@ -344,9 +347,6 @@ class ForeignAPIFile extends File {
                return $files;
        }
 
-       /**
-        * @see File::purgeCache()
-        */
        function purgeCache( $options = [] ) {
                $this->purgeThumbnails( $options );
                $this->purgeDescriptionPage();