summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Pearson <bubbafoley@gmail.com>2011-08-10 23:42:53 +0200
committerShane Pearson <bubbafoley@gmail.com>2011-08-10 23:42:53 +0200
commit6adfe636980da3a7b25e5b87ed8bcd1d008a1243 (patch)
treeae56861471ef4a26e8cc062eae2ad539d262d667
parent664a9357cd36be2f8e673cae3643318a695de5fb (diff)
Reset loaded files arrays in the Loader so the 404_override controller can access autoloaded libraries.
If a controller exists but a method is not found the current $CI instance is unset and a new one is created for the 404 override controller. Any autoloaded libraries will not be available to the 404 override controller because the Loader sees them as already have been loaded. To fix this we need to reset the loader. I implemented it via an initialize function that resets the loaded files arrays and then calls the autoloader. This also simplifies things in CI_Controller because it only has to call one loader function instead.
-rw-r--r--system/core/Controller.php2
-rw-r--r--system/core/Loader.php21
2 files changed, 12 insertions, 11 deletions
diff --git a/system/core/Controller.php b/system/core/Controller.php
index ec86b7920..fddb81e19 100644
--- a/system/core/Controller.php
+++ b/system/core/Controller.php
@@ -48,7 +48,7 @@ class CI_Controller {
$this->load =& load_class('Loader', 'core');
- $this->load->set_base_classes()->ci_autoloader();
+ $this->load->initialize();
log_message('debug', "Controller Class Initialized");
}
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 7c8b298ac..2b36c1cad 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -62,17 +62,22 @@ class CI_Loader {
// --------------------------------------------------------------------
/**
- * Set _base_classes variable
+ * Initialize the Loader
*
* This method is called once in CI_Controller.
*
* @param array
* @return object
*/
- public function set_base_classes()
+ public function initialize()
{
+ $this->_ci_classes = array();
+ $this->_ci_loaded_files = array();
+ $this->_ci_models = array();
$this->_base_classes =& is_loaded();
-
+
+ $this->_ci_autoloader();
+
return $this;
}
@@ -1020,23 +1025,19 @@ class CI_Loader {
* The config/autoload.php file contains an array that permits sub-systems,
* libraries, and helpers to be loaded automatically.
*
- * This function is public, as it's used in the CI_Controller class.
- * However, there is no reason you should ever needs to use it.
- *
* @param array
* @return void
*/
- public function ci_autoloader()
+ private function _ci_autoloader()
{
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
{
- include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
}
else
{
- include_once(APPPATH.'config/autoload.php');
+ include(APPPATH.'config/autoload.php');
}
-
if ( ! isset($autoload))
{