diff options
author | Andrey Andreev <narf@bofh.bg> | 2013-01-28 15:27:30 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2013-01-28 15:27:30 +0100 |
commit | 3608e1a094945631c5b65e1f66460e4486c5b541 (patch) | |
tree | 7f65af257040b2f94d74772d718c4d73db725270 | |
parent | 606fee0e2e0aa6a906db82e77090e91f133d7378 (diff) |
Libraries' filenames must be named in a ucfirst-like manner
-rw-r--r-- | system/core/Loader.php | 144 | ||||
-rw-r--r-- | system/libraries/Javascript.php | 2 | ||||
-rw-r--r-- | system/libraries/Javascript/Jquery.php (renamed from system/libraries/javascript/Jquery.php) | 0 | ||||
-rw-r--r-- | system/libraries/Javascript/index.html (renamed from system/libraries/javascript/index.html) | 0 | ||||
-rw-r--r-- | user_guide_src/source/installation/upgrade_300.rst | 34 |
5 files changed, 90 insertions, 90 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index bbd7a84b6..3ecce1676 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -97,13 +97,6 @@ class CI_Loader { protected $_ci_classes = array(); /** - * List of loaded files - * - * @var array - */ - protected $_ci_loaded_files = array(); - - /** * List of loaded models * * @var array @@ -943,117 +936,100 @@ class CI_Loader { // Was the path included with the class name? // We look for a slash to determine this - $subdir = ''; if (($last_slash = strrpos($class, '/')) !== FALSE) { // Extract the path - $subdir = substr($class, 0, ++$last_slash); + $subdir = ucfirst(substr($class, 0, ++$last_slash)); // Get the filename from the path $class = substr($class, $last_slash); } + else + { + $subdir = ''; + } + + $class = ucfirst($class); + $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; - // We'll test for both lowercase and capitalized versions of the file name - foreach (array(ucfirst($class), strtolower($class)) as $class) + // Is this a class extension request? + if (file_exists($subclass)) { - $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; + $baseclass = BASEPATH.'libraries/'.$class.'.php'; - // Is this a class extension request? - if (file_exists($subclass)) + if ( ! file_exists($baseclass)) { - $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; - - if ( ! file_exists($baseclass)) - { - log_message('error', 'Unable to load the requested class: '.$class); - show_error('Unable to load the requested class: '.$class); - } + log_message('error', 'Unable to load the requested class: '.$class); + show_error('Unable to load the requested class: '.$class); + } - // Safety: Was the class already loaded by a previous call? - if (in_array($subclass, $this->_ci_loaded_files)) + // Safety: Was the class already loaded by a previous call? + if (class_exists(config_item('subclass_prefix').$class, FALSE)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ($object_name !== NULL) { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); - } + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } - - $is_duplicate = TRUE; - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; } - include_once($baseclass); - include_once($subclass); - $this->_ci_loaded_files[] = $subclass; - - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; } - // Lets search for the requested library file and load it. - $is_duplicate = FALSE; - foreach ($this->_ci_library_paths as $path) - { - $filepath = $path.'libraries/'.$subdir.$class.'.php'; + include_once($baseclass); + include_once($subclass); - // Does the file exist? No? Bummer... - if ( ! file_exists($filepath)) - { - continue; - } + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + } + + // Lets search for the requested library file and load it. + foreach ($this->_ci_library_paths as $path) + { + $filepath = $path.'libraries/'.$subdir.$class.'.php'; - // Safety: Was the class already loaded by a previous call? - if (in_array($filepath, $this->_ci_loaded_files)) + // Safety: Was the class already loaded by a previous call? + if (class_exists($class, FALSE)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ($object_name !== NULL) { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_class($class, '', $params, $object_name); - } + return $this->_ci_init_class($class, '', $params, $object_name); } - - $is_duplicate = TRUE; - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; } - include_once($filepath); - $this->_ci_loaded_files[] = $filepath; - return $this->_ci_init_class($class, '', $params, $object_name); + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; + } + // Does the file exist? No? Bummer... + elseif ( ! file_exists($filepath)) + { + continue; } - } // END FOREACH + + include_once($filepath); + return $this->_ci_init_class($class, '', $params, $object_name); + } // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? if ($subdir === '') { - $path = strtolower($class).'/'.$class; - return $this->_ci_load_class($path, $params, $object_name); - } - elseif (ucfirst($subdir) != $subdir) - { - // Lowercase subdir failed - retry capitalized - $path = ucfirst($subdir).$class; - return $this->_ci_load_class($path, $params, $object_name); + return $this->_ci_load_class($class.'/'.$class, $params, $object_name); } // If we got this far we were unable to find the requested class. - // We do not issue errors if the load call failed due to a duplicate request - if ($is_duplicate === FALSE) - { - log_message('error', 'Unable to load the requested class: '.$class); - show_error('Unable to load the requested class: '.$class); - } + log_message('error', 'Unable to load the requested class: '.$class); + show_error('Unable to load the requested class: '.$class); } // -------------------------------------------------------------------- diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 7f1d85511..773a58384 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -69,7 +69,7 @@ class CI_Javascript { $this->CI =& get_instance(); // load the requested js library - $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload)); + $this->CI->load->library('Javascript/'.$js_library_driver, array('autoload' => $autoload)); // make js to refer to current library $this->js =& $this->CI->$js_library_driver; diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/Javascript/Jquery.php index b6e0434b2..b6e0434b2 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/Javascript/Jquery.php diff --git a/system/libraries/javascript/index.html b/system/libraries/Javascript/index.html index c942a79ce..c942a79ce 100644 --- a/system/libraries/javascript/index.html +++ b/system/libraries/Javascript/index.html diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 94f6321be..2d125a71a 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -104,16 +104,40 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' +******************************************* +Step 9: Update your librararies' file names +******************************************* + +CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner +(meaning that the first letter of the class name must be a capital). For example, +if you have the following library file: + + application/libraries/mylibrary.php + +... then you'll have to rename it to: + + application/libraries/Mylibrary.php + +The same goes for driver libraries and extensions and/or overrides of CodeIgniter's +own libraries and core classes. + + application/libraries/MY_email.php + application/core/MY_log.php + +The above files should respectively be renamed to the following: + + application/libraries/MY_Email.php + application/core/MY_Log.php **************************************************************************** -Step 9: Check the calls to Array Helper's element() and elements() functions +Step 10: Check the calls to Array Helper's element() and elements() functions **************************************************************************** The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. ************************************************************* -Step 10: Update usage of Database Forge's drop_table() method +Step 11: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -135,7 +159,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 11: Change usage of Email library with multiple emails +Step 12: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -150,7 +174,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 12: Update your Form_validation language lines +Step 13: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -181,7 +205,7 @@ files and error messages format: later. **************************************************************** -Step 13: Remove usage of (previously) deprecated functionalities +Step 14: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a |