From 39b1c11f5976104dce30fe83e1d3c6f9ed616122 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 4 Jun 2012 16:51:14 -0500 Subject: Direct return from mimes config, instead of using global $mimes; Global variables are generally a terrible idea, especially for something as simple as this. The mimes.php now returns an array instead of just injecting a variable name into the global namespace. --- system/helpers/download_helper.php | 4 ++-- system/helpers/file_helper.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 9c390a7f7..3c677055f 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -75,11 +75,11 @@ if ( ! function_exists('force_download')) // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + $mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config/mimes.php'); + $mimes = include(APPPATH.'config/mimes.php'); } // Only change the default MIME if we can find one diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 0061c4285..068706c30 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -349,17 +349,17 @@ if ( ! function_exists('get_mime_by_extension')) { $extension = strtolower(substr(strrchr($file, '.'), 1)); - global $mimes; + static $mimes; if ( ! is_array($mimes)) { if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + $mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config/mimes.php'); + $mimes = include(APPPATH.'config/mimes.php'); } if ( ! is_array($mimes)) -- cgit v1.2.3-24-g4f1b