diff options
-rw-r--r-- | system/core/Config.php | 10 | ||||
-rw-r--r-- | tests/codeigniter/core/Config_test.php | 10 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/installation/upgrade_300.rst | 19 | ||||
-rw-r--r-- | user_guide_src/source/libraries/config.rst | 2 |
5 files changed, 27 insertions, 18 deletions
diff --git a/system/core/Config.php b/system/core/Config.php index 7e64444bc..109ee6424 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -184,16 +184,16 @@ class CI_Config { * * @param string $item Config item name * @param string $index Index name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function item($item, $index = '') { if ($index == '') { - return isset($this->config[$item]) ? $this->config[$item] : FALSE; + return isset($this->config[$item]) ? $this->config[$item] : NULL; } - return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : FALSE; + return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL; } // -------------------------------------------------------------------- @@ -202,13 +202,13 @@ class CI_Config { * Fetch a config file item with slash appended (if not empty) * * @param string $item Config item name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function slash_item($item) { if ( ! isset($this->config[$item])) { - return FALSE; + return NULL; } elseif (trim($this->config[$item]) === '') { diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index e3be8a3fc..ba9a2c070 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -24,18 +24,18 @@ class Config_test extends CI_TestCase { $this->assertEquals($this->cfg['base_url'], $this->config->item('base_url')); // Bad Config value - $this->assertFalse($this->config->item('no_good_item')); + $this->assertNull($this->config->item('no_good_item')); // Index - $this->assertFalse($this->config->item('no_good_item', 'bad_index')); - $this->assertFalse($this->config->item('no_good_item', 'default')); + $this->assertNull($this->config->item('no_good_item', 'bad_index')); + $this->assertNull($this->config->item('no_good_item', 'default')); } // -------------------------------------------------------------------- public function test_set_item() { - $this->assertFalse($this->config->item('not_yet_set')); + $this->assertNull($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')); @@ -46,7 +46,7 @@ class Config_test extends CI_TestCase { public function test_slash_item() { // Bad Config value - $this->assertFalse($this->config->slash_item('no_good_item')); + $this->assertNull($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')); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 5eda25e15..1e463db8d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -130,6 +130,7 @@ Release Date: Not Released - Added *colors* configuration to allow customization for the *background*, *border*, *text* and *grid* colors. - :doc:`Directory Helper <helpers/directory_helper>` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array. + - :doc:`Array Helper <helpers/array_helper>` :php:func:`element()` and :php:func:`elements()` now return NULL instead of FALSE when the required elements don't exist. - :doc:`Language Helper <helpers/language_helper>` :php:func:`lang()` now accepts an optional list of additional HTML attributes. - Deprecated the :doc:`Email Helper <helpers/email_helper>` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively. @@ -406,7 +407,8 @@ Release Date: Not Released - :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. + - Removed internal method ``_assign_to_config()`` and moved its implementation to *CodeIgniter.php* instead. + - ``item()`` now returns NULL instead of FALSE when the required config item doesn't exist. - :doc:`Security Library <libraries/security>` changes include: diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 3e8307cfc..0eafaf9cd 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -145,22 +145,29 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' +************************************************* +Step 10: Check the calls to config->item() method +************************************************* + +This method now returns NULL instead of FALSE when the required config +item doesn't exist. + ***************************************************************************** -Step 10: Check the calls to Array Helper's element() and elements() functions +Step 11: 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 11: Check the calls to Directory Helper's directory_map() function +Step 12: Check the calls to Directory Helper's directory_map() function *********************************************************************** In the resulting array, directories now end with a trailing directory separator (i.e. a slash, usually). ************************************************************* -Step 12: Update usage of Database Forge's drop_table() method +Step 13: 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 @@ -182,7 +189,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 13: Change usage of Email library with multiple emails +Step 14: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -197,7 +204,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 14: Update your Form_validation language lines +Step 15: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -228,7 +235,7 @@ files and error messages format: later. **************************************************************** -Step 15: Remove usage of (previously) deprecated functionalities +Step 16: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 08d9c2905..654dc4ded 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -90,7 +90,7 @@ example, to fetch your language choice you'll do this:: $lang = $this->config->item('language'); -The function returns FALSE (boolean) if the item you are trying to fetch +The function returns NULL if the item you are trying to fetch does not exist. If you are using the second parameter of the $this->config->load |