summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/core/Config.php69
-rwxr-xr-xsystem/core/Security.php2
-rw-r--r--tests/codeigniter/core/Config_test.php13
3 files changed, 38 insertions, 46 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index d8a606c14..ca865cebf 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -120,74 +120,61 @@ class CI_Config {
foreach ($this->_config_paths as $path)
{
- $found = FALSE;
- foreach (array(ENVIRONMENT.'/'.$file, $file) as $location)
+ foreach (array($file, ENVIRONMENT.'/'.$file) as $location)
{
$file_path = $path.'config/'.$location.'.php';
if (in_array($file_path, $this->is_loaded, TRUE))
{
- $loaded = TRUE;
- continue 2;
+ return TRUE;
}
- if (file_exists($file_path))
+ if ( ! file_exists($file_path))
{
- $found = TRUE;
- break;
+ continue;
}
- }
-
- if ($found === FALSE)
- {
- continue;
- }
- include($file_path);
+ include($file_path);
- if ( ! isset($config) OR ! is_array($config))
- {
- if ($fail_gracefully === TRUE)
+ if ( ! isset($config) OR ! is_array($config))
{
- return FALSE;
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+
+ show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
- show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
- }
- if ($use_sections === TRUE)
- {
- if (isset($this->config[$file]))
+ if ($use_sections === TRUE)
{
- $this->config[$file] = array_merge($this->config[$file], $config);
+ $this->config[$file] = isset($this->config[$file])
+ ? array_merge($this->config[$file], $config)
+ : $config;
}
else
{
- $this->config[$file] = $config;
+ $this->config = array_merge($this->config, $config);
}
+
+ $this->is_loaded[] = $file_path;
+ $config = NULL;
+ $loaded = TRUE;
+ log_message('debug', 'Config file loaded: '.$file_path);
}
- else
+
+ if ($loaded === TRUE)
{
- $this->config = array_merge($this->config, $config);
+ return TRUE;
}
-
- $this->is_loaded[] = $file_path;
- unset($config);
-
- $loaded = TRUE;
- log_message('debug', 'Config file loaded: '.$file_path);
- break;
}
- if ($loaded === FALSE)
+ if ($fail_gracefully === TRUE)
{
- if ($fail_gracefully === TRUE)
- {
- return FALSE;
- }
- show_error('The configuration file '.$file.'.php does not exist.');
+ return FALSE;
}
- return TRUE;
+ show_error('The configuration file '.$file.'.php does not exist.');
}
// --------------------------------------------------------------------
diff --git a/system/core/Security.php b/system/core/Security.php
index 8adc35676..8ad0518a4 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -673,7 +673,7 @@ class CI_Security {
// Decode numeric & UTF16 two byte entities
$str = html_entity_decode(
- preg_replace('/(&#(?:x0*[0-9a-f]{2,5}(?![0-9a-f;]))|(?:0*\d{2,4}(?![0-9;])))/iS', '$1;', $str),
+ preg_replace('/(&#(?:x0*[0-9a-f]{2,5}(?![0-9a-f;])|(?:0*\d{2,4}(?![0-9;]))))/iS', '$1;', $str),
$flag,
$charset
);
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index 8e312e361..f125fc6e9 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -205,13 +205,18 @@ class Config_test extends CI_TestCase {
'number' => 42,
'letter' => 'Z'
);
+
$pkg_dir = 'package';
- $this->ci_vfs_create($file.'.php', '<?php $config = '.var_export($cfg2, TRUE).';', $this->ci_app_root,
- array($pkg_dir, 'config'));
- $this->config->_config_paths[] = $this->ci_vfs_path($pkg_dir.'/', APPPATH);
+ $this->ci_vfs_create(
+ $file.'.php',
+ '<?php $config = '.var_export($cfg2, TRUE).';',
+ $this->ci_app_root,
+ array($pkg_dir, 'config')
+ );
+ array_unshift($this->config->_config_paths, $this->ci_vfs_path($pkg_dir.'/', APPPATH));
$this->assertTrue($this->config->load($file, TRUE));
$this->assertEquals(array_merge($cfg, $cfg2), $this->config->item($file));
- array_pop($this->config->_config_paths);
+ array_shift($this->config->_config_paths);
// Test graceful fail of invalid file
$file = 'badfile';