diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2016-09-18 17:22:36 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2016-09-19 19:55:09 +0000 |
commit | f7e3ac3f95ce2b5a9f73326e854d1c301b513078 (patch) | |
tree | fe70905a0d7b96c6b1fa311808a0790bb6ad55fc /includes/filebackend/FSFile.php | |
parent | 95eed85fb9c085cd2da8200335ec16640054e18f (diff) | |
download | mediawikicore-f7e3ac3f95ce2b5a9f73326e854d1c301b513078.tar.gz mediawikicore-f7e3ac3f95ce2b5a9f73326e854d1c301b513078.zip |
FSFile and TempFSFile cleanups
* Remove wf* function dependencies. This includes wfTempDir().
Callers now should specify the directory, though it will try to do
most of the wfTempDir() logic anyway if they do not.
* Update callers to inject wfTempDir() so $wgTmpDirectory is used by
TempFSFile instead of it probing to find a valid directory itself.
* Move most of the wfTempDir() logic to TempFSFile::getUsableTempDirectory().
* Remove unused getMimeType() method.
Change-Id: Idd55936b07f9448a6c90577708722b7b52b8fe66
Diffstat (limited to 'includes/filebackend/FSFile.php')
-rw-r--r-- | includes/filebackend/FSFile.php | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/includes/filebackend/FSFile.php b/includes/filebackend/FSFile.php index 8aa11b6565ec..221fe9fce298 100644 --- a/includes/filebackend/FSFile.php +++ b/includes/filebackend/FSFile.php @@ -86,15 +86,6 @@ class FSFile { } /** - * Guess the MIME type from the file contents alone - * - * @return string - */ - public function getMimeType() { - return MimeMagic::singleton()->guessMimeType( $this->path, false ); - } - - /** * Get an associative array containing information about * a file with the given storage path. * @@ -117,8 +108,6 @@ class FSFile { * @return array */ public function getProps( $ext = true ) { - wfDebug( __METHOD__ . ": Getting file info for $this->path\n" ); - $info = self::placeholderProps(); $info['fileExists'] = $this->exists(); @@ -131,7 +120,7 @@ class FSFile { } # MIME type according to file contents - $info['file-mime'] = $this->getMimeType(); + $info['file-mime'] = $magic->guessMimeType( $this->path, false ); # logical MIME type $info['mime'] = $magic->improveTypeFromExtension( $info['file-mime'], $ext ); @@ -145,17 +134,15 @@ class FSFile { $handler = MediaHandler::getHandler( $info['mime'] ); if ( $handler ) { $tempImage = (object)[]; // XXX (hack for File object) + /** @noinspection PhpParamsInspection */ $info['metadata'] = $handler->getMetadata( $tempImage, $this->path ); + /** @noinspection PhpParamsInspection */ $gis = $handler->getImageSize( $tempImage, $this->path, $info['metadata'] ); if ( is_array( $gis ) ) { $info = $this->extractImageSizeInfo( $gis ) + $info; } } $info['sha1'] = $this->getSha1Base36(); - - wfDebug( __METHOD__ . ": $this->path loaded, {$info['size']} bytes, {$info['mime']}.\n" ); - } else { - wfDebug( __METHOD__ . ": $this->path NOT FOUND!\n" ); } return $info; |