Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Specify type all lowercase in MIME type config.

  • Loading branch information...
commit d83aa9bd20a9891b22ff35ceaeb27fa20daa32f4 1 parent aadf2ff
@davidpersson authored
View
12 bootstrap.php
@@ -60,32 +60,32 @@
/*
* Configure the MIME type detection. The detection class is two headed which means it
* uses both a glob (for matching against file extensions) and a magic adapter (for
- * detecting the type from the content of files). Available `Glob` adapters are `Apache`,
- * `Freedesktop`, `Memory` and `Php`. These adapters are also available as a `Magic`
+ * detecting the type from the content of files). Available `glob` adapters are `Apache`,
+ * `Freedesktop`, `Memory` and `Php`. These adapters are also available as a `magic`
* variant with the addtion of a `Fileinfo` magic adapter. Not all adapters require
* a file to be passed along with the configuration.
*/
require_once 'Mime/Type.php';
if ($hasFileinfo) {
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Fileinfo'
));
} else {
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$mm}/data/magic.db"
));
}
if ($cached = $cacheRead('mime_type_glob')) {
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Memory'
));
foreach ($cached as $item) {
Mime_Type::$glob->register($item);
}
} else {
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$mm}/data/glob.db"
));
View
14 src/Mime/Type.php
@@ -84,12 +84,21 @@ class Mime_Type {
/**
* Set and change configuration during runtime.
*
- * @param string $type Either "Magic" or "Glob"
+ * @param string $type Either `'magic'` or `'glob'`.
* @param array $config Config specifying engine and db
* e.g. `array('adapter' => 'Fileinfo', 'file' => '/etc/magic')`.
*/
public static function config($type, array $config = array()) {
- if ($type != 'Magic' && $type != 'Glob') {
+ if ($type == 'Magic' || $type == 'Glob') {
+ $message = 'Previously types could be specified with a leading capital';
+ $message .= 'letter (i.e. `Magic` instead of `magic`). Support for';
+ $message .= 'this has been deprecated and the all lowercase version should';
+ $message .= 'be used. However for now capitalized types continue to work';
+ trigger_error($message, E_USER_DEPRECATED);
+
+ $type[0] = strtolower($type[0]);
+ }
+ if ($type != 'magic' && $type != 'glob') {
throw new OutOfBoundsExeption("Invalid type `{$type}`.");
}
@@ -98,7 +107,6 @@ public static function config($type, array $config = array()) {
require_once $file;
- $type[0] = strtolower($type[0]);
self::${$type} = new $class($config);
}
View
4 tests/functional/Media/Process/ConversionTest.php
@@ -27,11 +27,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(dirname(__FILE__)))) . '/data';
$this->_data = dirname(dirname(dirname(dirname(dirname(__FILE__))))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => $this->_data . '/magic.db'
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => $this->_data . '/glob.db'
));
View
4 tests/unit/Media/InfoTest.php
@@ -31,11 +31,11 @@ protected function setUp() {
'document' => new Media_Info_Adapter_GenericMock(null),
'video' => new Media_Info_Adapter_GenericMock(null)
));
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Media/Process/Adapter/FfmpegShellTest.php
@@ -34,11 +34,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data';
$this->_data = dirname(dirname(dirname((dirname(dirname(dirname(__FILE__))))))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Media/Process/Adapter/GdTest.php
@@ -28,11 +28,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data';
$this->_data = dirname(dirname(dirname((dirname(dirname(dirname(__FILE__))))))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Media/Process/Adapter/ImagickTest.php
@@ -28,11 +28,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data';
$this->_data = dirname(dirname(dirname((dirname(dirname(dirname(__FILE__))))))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Media/Process/Adapter/SoxShellTest.php
@@ -31,11 +31,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data';
$this->_data = dirname(dirname(dirname((dirname(dirname(dirname(__FILE__))))))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Media/ProcessTest.php
@@ -31,11 +31,11 @@ protected function setUp() {
'document' => new Media_Process_Adapter_GenericMock(null),
'video' => new Media_Process_Adapter_GenericMock(null)
));
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/magic.db"
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => "{$this->_data}/glob.db"
));
View
4 tests/unit/Mime/TypeTest.php
@@ -23,11 +23,11 @@ protected function setUp() {
$this->_files = dirname(dirname(dirname(__FILE__))) . '/data';
$this->_data = dirname(dirname(dirname(dirname(__FILE__)))) .'/data';
- Mime_Type::config('Magic', array(
+ Mime_Type::config('magic', array(
'adapter' => 'Freedesktop',
'file' => $this->_data . '/magic.db'
));
- Mime_Type::config('Glob', array(
+ Mime_Type::config('glob', array(
'adapter' => 'Freedesktop',
'file' => $this->_data . '/glob.db'
));
Please sign in to comment.
Something went wrong with that request. Please try again.