Fixed regression in file type detection -- use the real file extension not the tempor...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 18 Jun 2007 06:35:20 +0000 (06:35 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 18 Jun 2007 06:35:20 +0000 (06:35 +0000)
includes/SpecialUpload.php
includes/filerepo/File.php

index 38e670e..a223341 100644 (file)
@@ -108,7 +108,6 @@ class UploadForm {
                $this->mFileSize       = $request->getFileSize( 'wpUploadFile' );
                $this->mSrcName        = $request->getFileName( 'wpUploadFile' );
                $this->mCurlError      = $request->getUploadError( 'wpUploadFile' );
-               $this->mFileProps      = File::getPropsFromPath( $this->mTempPath );
                $this->mSessionKey     = false;
                $this->mStashed        = false;
                $this->mRemoveTempFile = false; // PHP will handle this
@@ -360,6 +359,7 @@ class UploadForm {
                 * probably not accept it.
                 */
                if( !$this->mStashed ) {
+                       $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $finalExt );
                        $this->checkMacBinary();
                        $veri = $this->verify( $this->mTempPath, $finalExt );
 
index 4325f79..42ea9e7 100644 (file)
@@ -1001,9 +1001,13 @@ class File {
        }
 
        /**
-        * Get an associative array containing information about a file in the local filesystem
+        * Get an associative array containing information about a file in the local filesystem\
+        *
+        * @param string $path Absolute local filesystem path
+        * @param mixed $ext The file extension, or true to extract it from the filename. 
+        *                   Set it to false to ignore the extension.
         */
-       static function getPropsFromPath( $path ) {
+       static function getPropsFromPath( $path, $ext = true ) {
                wfProfileIn( __METHOD__ );
                wfDebug( __METHOD__.": Getting file info for $path\n" );
                $info = array( 'fileExists' => file_exists( $path ) );
@@ -1011,7 +1015,7 @@ class File {
                if ( $info['fileExists'] ) {
                        $magic = MimeMagic::singleton();
 
-                       $info['mime'] = $magic->guessMimeType( $path, true );
+                       $info['mime'] = $magic->guessMimeType( $path, $ext );
                        list( $info['major_mime'], $info['minor_mime'] ) = self::splitMime( $info['mime'] );
                        $info['media_type'] = $magic->getMediaType( $path, $info['mime'] );