summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2013-08-17 07:31:29 +0200
committervlakoff <vlakoff@gmail.com>2013-08-17 16:39:02 +0200
commit8d70c0af8f395cfa6354e4e586b156f65954fca3 (patch)
tree03fcac4d3f2a88b188e08d0378b1ee302e7e88a2
parente19b5557e8c2c074db0c1c104c26a7b23d9d9b6f (diff)
Fix $replace parameter handling in get_config()
Code was reached only on first function call, then short-circuited because of the reference cache.
-rw-r--r--system/core/CodeIgniter.php2
-rw-r--r--system/core/Common.php58
2 files changed, 32 insertions, 28 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index a026920a4..c962fda20 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -88,7 +88,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* The subclass prefix allows CI to know if a core class is
* being extended via a library in the local application
* "libraries" folder. Since CI allows config items to be
- * overriden via data set in the main index. php file,
+ * overriden via data set in the main index.php file,
* before proceeding we need to know if a subclass_prefix
* override exists. If so, we will set this value now,
* before any classes are loaded
diff --git a/system/core/Common.php b/system/core/Common.php
index 21e1df9c6..a90a3ab70 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -230,39 +230,43 @@ if ( ! function_exists('get_config'))
if (isset($_config))
{
- return $_config[0];
+ $config =& $_config[0];
}
-
- $file_path = APPPATH.'config/config.php';
- $found = FALSE;
- if (file_exists($file_path))
+ else
{
- $found = TRUE;
- require($file_path);
- }
+ $file_path = APPPATH.'config/config.php';
+ $found = FALSE;
+ if (file_exists($file_path))
+ {
+ $found = TRUE;
+ require($file_path);
+ }
- // Is the config file in the environment folder?
- if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
- {
- require($file_path);
- }
- elseif ( ! $found)
- {
- set_status_header(503);
- echo 'The configuration file does not exist.';
- exit(EXIT_CONFIG);
- }
+ // Is the config file in the environment folder?
+ if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
+ {
+ require($file_path);
+ }
+ elseif ( ! $found)
+ {
+ set_status_header(503);
+ echo 'The configuration file does not exist.';
+ exit(EXIT_CONFIG);
+ }
- // Does the $config array exist in the file?
- if ( ! isset($config) OR ! is_array($config))
- {
- set_status_header(503);
- echo 'Your config file does not appear to be formatted correctly.';
- exit(EXIT_CONFIG);
+ // Does the $config array exist in the file?
+ if ( ! isset($config) OR ! is_array($config))
+ {
+ set_status_header(503);
+ echo 'Your config file does not appear to be formatted correctly.';
+ exit(EXIT_CONFIG);
+ }
+
+ $_config[0] =& $config;
}
// Are any values being dynamically replaced?
- if (count($replace) > 0)
+ if (!empty($replace))
{
foreach ($replace as $key => $val)
{
@@ -273,7 +277,7 @@ if ( ! function_exists('get_config'))
}
}
- return $_config[0] =& $config;
+ return $config;
}
}