diff --git a/CHANGELOG b/CHANGELOG index b380cc37d..823f6da7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ Version 1.1.13 work in progress - Bug #1347: CDbTestCase: table name in fixtures list enclosed into double curly brackets (e.g. 'tasks'=>':{{task}}') didn't worked properly (resurtm) - Bug #1351: CClientScript::registerMetaTag() now allows to register multiple meta tags with the same set of attributes (klimov-paul) - Bug #1364: Empty CHtml::$errorCss cause class attribute rendering errors (creocoder) +- Bug #1393: CFileHelper::getMimeTypeByExtension() used to treat $magicFile parameter as array with MIME-types, but not the string containing path of the file with MIME-types as it should be (resurtm) - Enh #117: Added CPhpMessageSource::$extensionPaths to allow extensions, that do not have a base class to use as category prefix, to register message source (rcoelho, cebe) - Enh #291: CFormatter::formatDate and formatDateTime now also accept strings in strtotime() format (francis_tm, cebe) - Enh #486: CHttpSession::$gCProbability and CDbHttpSession::$gCProbability are floats now. Minimal possible $gCProbability value has been changed to the ≈0.00000005% (1/2147483647), was integer 1% before, default value left unchanged (1%) (resurtm) diff --git a/framework/utils/CFileHelper.php b/framework/utils/CFileHelper.php index 03bfc9b32..ee0f5b283 100644 --- a/framework/utils/CFileHelper.php +++ b/framework/utils/CFileHelper.php @@ -213,7 +213,9 @@ class CFileHelper * @param string $file the file name. * @param string $magicFile name of a magic database file, usually something like /path/to/magic.mime. * This will be passed as the second parameter to {@link http://php.net/manual/en/function.finfo-open.php finfo_open}. - * This parameter has been available since version 1.1.3. + * Magic file format described in {@link http://linux.die.net/man/5/magic man 5 magic}, note that this file does not + * contain a standard PHP array as you might suppose. Specified magic file will be used only when fileinfo + * PHP extension is available. This parameter has been available since version 1.1.3. * @param boolean $checkExtension whether to check the file extension in case the MIME type cannot be determined * based on finfo and mime_content_type. Defaults to true. This parameter has been available since version 1.1.4. * @return string the MIME type. Null is returned if the MIME type cannot be determined. @@ -246,14 +248,18 @@ class CFileHelper */ public static function getMimeTypeByExtension($file,$magicFile=null) { - static $extensions; - if($extensions===null) - $extensions=$magicFile===null ? require(Yii::getPathOfAlias('system.utils.mimeTypes').'.php') : $magicFile; + static $extensions, $customExtensions; + if($magicFile===null && $extensions===null) + $extensions=require(Yii::$customExtensions('system.utils.mimeTypes').'.php'); + else if($magicFile!==null && $customExtensions===null) + $customExtensions=require($magicFile); if(($ext=pathinfo($file, PATHINFO_EXTENSION))!=='') { $ext=strtolower($ext); if(isset($extensions[$ext])) return $extensions[$ext]; + else if(isset($customExtensions[$ext])) + return $customExtensions[$ext]; } return null; }