summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/core/CodeIgniter.php7
-rw-r--r--system/core/Config.php80
-rw-r--r--system/core/Exceptions.php2
-rw-r--r--tests/codeigniter/core/Config_test.php25
-rw-r--r--user_guide_src/source/changelog.rst8
5 files changed, 47 insertions, 75 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index f3592eaf9..324b4d849 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -130,9 +130,12 @@
$CFG =& load_class('Config', 'core');
// Do we have any manually set config items in the index.php file?
- if (isset($assign_to_config))
+ if (isset($assign_to_config) && is_array($assign_to_config))
{
- $CFG->_assign_to_config($assign_to_config);
+ foreach ($assign_to_config as $key => $value)
+ {
+ $CFG->set_item($key, $value);
+ }
}
/*
diff --git a/system/core/Config.php b/system/core/Config.php
index e78128c76..152e9af68 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -26,7 +26,7 @@
*/
/**
- * CodeIgniter Config Class
+ * Config Class
*
* This class contains functions that enable config files to be managed
*
@@ -41,29 +41,31 @@ class CI_Config {
/**
* List of all loaded config values
*
- * @var array
+ * @var array
*/
public $config = array();
/**
* List of all loaded config files
*
- * @var array
+ * @var array
*/
public $is_loaded = array();
/**
* List of paths to search when trying to load a config file.
- * This must be public as it's used by the Loader class.
*
- * @var array
+ * @used-by CI_Loader Must be public
+ * @var array
*/
public $_config_paths = array(APPPATH);
/**
- * Constructor
+ * Class constructor
*
- * Sets the $config data from the primary config.php file as a class variable
+ * Sets the $config data from the primary config.php file as a class variable.
+ *
+ * @return void
*/
public function __construct()
{
@@ -93,10 +95,10 @@ class CI_Config {
/**
* Load Config File
*
- * @param string the config file name
- * @param bool if configuration values should be loaded into their own section
- * @param bool true if errors should just return false, false if an error message should be displayed
- * @return bool if the file was loaded correctly
+ * @param string $file Configuration file name
+ * @param bool $use_sections Whether configuration values should be loaded into their own section
+ * @param bool $fail_gracefully Whether to just return FALSE or display an error message
+ * @return bool TRUE if the file was loaded correctly or FALSE on failure
*/
public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
@@ -183,9 +185,9 @@ class CI_Config {
/**
* Fetch a config file item
*
- * @param string the config item name
- * @param string the index name
- * @return string
+ * @param string $item Config item name
+ * @param string $index Index name
+ * @return string|bool The configuration item or FALSE on failure
*/
public function item($item, $index = '')
{
@@ -200,10 +202,10 @@ class CI_Config {
// --------------------------------------------------------------------
/**
- * Fetch a config file item - adds slash after item (if item is not empty)
+ * Fetch a config file item with slash appended (if not empty)
*
- * @param string the config item name
- * @return string
+ * @param string $item Config item name
+ * @return string|bool The configuration item or FALSE on failure
*/
public function slash_item($item)
{
@@ -223,9 +225,12 @@ class CI_Config {
/**
* Site URL
+ *
* Returns base_url . index_page [. uri_string]
*
- * @param mixed the URI string or an array of segments
+ * @uses CI_Config::_uri_string()
+ *
+ * @param string|string[] $uri URI string or an array of segments
* @return string
*/
public function site_url($uri = '')
@@ -264,9 +269,12 @@ class CI_Config {
/**
* Base URL
+ *
* Returns base_url [. uri_string]
*
- * @param string $uri
+ * @uses CI_Config::_uri_string()
+ *
+ * @param string|string[] $uri URI string or an array of segments
* @return string
*/
public function base_url($uri = '')
@@ -277,9 +285,12 @@ class CI_Config {
// -------------------------------------------------------------
/**
- * Build URI string for use in Config::site_url() and Config::base_url()
+ * Build URI string
+ *
+ * @used-by CI_Config::site_url()
+ * @used-by CI_Config::base_url()
*
- * @param mixed $uri
+ * @param string|string[] $uri URI string or an array of segments
* @return string
*/
protected function _uri_string($uri)
@@ -318,8 +329,8 @@ class CI_Config {
/**
* Set a config file item
*
- * @param string the config item key
- * @param string the config item value
+ * @param string $item Config item key
+ * @param string $value Config item value
* @return void
*/
public function set_item($item, $value)
@@ -327,29 +338,6 @@ class CI_Config {
$this->config[$item] = $value;
}
- // --------------------------------------------------------------------
-
- /**
- * Assign to Config
- *
- * This function is called by the front controller (CodeIgniter.php)
- * after the Config class is instantiated. It permits config items
- * to be assigned or overriden by variables contained in the index.php file
- *
- * @param array
- * @return void
- */
- public function _assign_to_config($items = array())
- {
- if (is_array($items))
- {
- foreach ($items as $key => $val)
- {
- $this->set_item($key, $val);
- }
- }
- }
-
}
/* End of file Config.php */
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index c0caf2e7d..556257729 100644
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -130,7 +130,7 @@ class CI_Exceptions {
* @param string $heading Page heading
* @param string|string[] $message Error message
* @param string $template Template name
- * @param int $statis_code (default: 500)
+ * @param int $status_code (default: 500)
*
* @return string Error page output
*/
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index d652a625e..be426d070 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -9,7 +9,7 @@ class Config_test extends CI_TestCase {
// set predictable config values
$this->cfg = array(
'index_page' => 'index.php',
- 'base_url' => 'http://example.com/',
+ 'base_url' => 'http://example.com/',
'subclass_prefix' => 'MY_'
);
$this->ci_set_config($this->cfg);
@@ -38,7 +38,6 @@ class Config_test extends CI_TestCase {
$this->assertFalse($this->config->item('not_yet_set'));
$this->config->set_item('not_yet_set', 'is set');
-
$this->assertEquals('is set', $this->config->item('not_yet_set'));
}
@@ -50,7 +49,6 @@ class Config_test extends CI_TestCase {
$this->assertFalse($this->config->slash_item('no_good_item'));
$this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url'));
-
$this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix'));
}
@@ -124,7 +122,7 @@ class Config_test extends CI_TestCase {
$q_string = $this->config->item('enable_query_strings');
$this->config->set_item('enable_query_strings', FALSE);
- $uri= 'test';
+ $uri = 'test';
$uri2 = '1';
$this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri));
$this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2)));
@@ -137,7 +135,6 @@ class Config_test extends CI_TestCase {
$this->assertEquals($index_page.'/'.$uri.$suffix.'?'.$arg, $this->config->site_url($uri.'?'.$arg));
$this->config->set_item('url_suffix', FALSE);
-
$this->config->set_item('enable_query_strings', TRUE);
$this->assertEquals($index_page.'?'.$uri, $this->config->site_url($uri));
@@ -233,22 +230,4 @@ class Config_test extends CI_TestCase {
$this->assertNull($this->config->load($file));
}
- // --------------------------------------------------------------------
-
- public function test_assign_to_config()
- {
- $key1 = 'test';
- $key2 = '1';
- $val1 = 'foo';
- $val2 = 'bar';
- $cfg = array(
- $key1 => $val1,
- $key2 => $val2
- );
-
- $this->assertNull($this->config->_assign_to_config($cfg));
- $this->assertEquals($val1, $this->config->item($key1));
- $this->assertEquals($val2, $this->config->item($key2));
- }
-
} \ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index e91fafccc..a1cdcd475 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -236,8 +236,8 @@ Release Date: Not Released
- Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
- ``CI_Loader::_ci_autoloader()`` is now a protected method.
- Added autoloading of drivers with ``$autoload['drivers']``.
- - ``CI_Loader::library()`` will now load drivers as well, for backward compatibility of converted libraries (like Session).
- - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as *<?=* will always be available.
+ - ``CI_Loader::library()`` will now load drivers as well, for backward compatibility of converted libraries (like :doc:`Session <libraries/sessions>`).
+ - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``<?=`` will always be available.
- :doc:`Input Library <libraries/input>` changes include:
- Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
- Modified ``valid_ip()`` to use PHP's ``filter_var()``.
@@ -254,7 +254,9 @@ Release Date: Not Released
- Added method ``get_content_type()``.
- Added a second argument to method ``set_content_type()`` that allows setting the document charset as well.
- ``$config['time_reference']`` now supports all timezone strings supported by PHP.
- - Changed :doc:`Config Library <libraries/config>` method ``site_url()`` to accept an array as well.
+ - :doc:`Config Library <libraries/config>` changes include:
+ - Changed ``site_url()`` method to accept an array as well.
+ - Removed internal method ``_assign_to_config()`` and moved it's implementation in *CodeIgniter.php* instead.
- :doc:`Security Library <libraries/security>` changes include:
- Added method ``strip_image_tags()``.
- Added ``$config['csrf_regeneration']``, which makes token regeneration optional.