summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-10-05 23:00:08 +0200
committerAndrey Andreev <narf@devilix.net>2014-10-05 23:00:08 +0200
commitd444d445ed0458a352ecb9ff79ffd158677ee805 (patch)
treedcdbe4b38dbb343498b2ea2a37556cb358cd5720
parent86d7eadf102c798f2aa70a86e86fd0f5050d9574 (diff)
config_item() to return NULL instead of FALSE for non-existing items
Close #3001 Close #3232 Related: #3244
-rw-r--r--system/core/Common.php2
-rw-r--r--system/core/Exceptions.php16
-rw-r--r--system/core/Input.php2
-rwxr-xr-xsystem/core/Security.php6
-rw-r--r--system/libraries/Encrypt.php2
-rw-r--r--tests/mocks/core/common.php2
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/general/common_functions.rst2
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst4
9 files changed, 23 insertions, 14 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index b5a696c68..504e22571 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -289,7 +289,7 @@ if ( ! function_exists('config_item'))
$_config[0] =& get_config();
}
- return isset($_config[0][$item]) ? $_config[0][$item] : FALSE;
+ return isset($_config[0][$item]) ? $_config[0][$item] : NULL;
}
}
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index cb4bc3cd6..49c2217c9 100644
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -145,9 +145,11 @@ class CI_Exceptions {
*/
public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
- $templates_path = config_item('error_views_path')
- ? config_item('error_views_path')
- : VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ $templates_path = config_item('error_views_path');
+ if (empty($templates_path))
+ {
+ $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ }
if (is_cli())
{
@@ -185,9 +187,11 @@ class CI_Exceptions {
*/
public function show_php_error($severity, $message, $filepath, $line)
{
- $templates_path = config_item('error_views_path')
- ? config_item('error_views_path')
- : VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ $templates_path = config_item('error_views_path');
+ if (empty($templates_path))
+ {
+ $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
+ }
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
diff --git a/system/core/Input.php b/system/core/Input.php
index ada9fc680..9ae2f6d6f 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -353,7 +353,7 @@ class CI_Input {
$path = config_item('cookie_path');
}
- if ($secure === FALSE && config_item('cookie_secure') !== FALSE)
+ if ($secure === FALSE && config_item('cookie_secure') === TRUE)
{
$secure = config_item('cookie_secure');
}
diff --git a/system/core/Security.php b/system/core/Security.php
index 15a66430a..cffdb9ad9 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -158,7 +158,7 @@ class CI_Security {
public function __construct()
{
// Is CSRF protection enabled?
- if (config_item('csrf_protection') === TRUE)
+ if (config_item('csrf_protection'))
{
// CSRF config
foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
@@ -170,9 +170,9 @@ class CI_Security {
}
// Append application specific cookie prefix
- if (config_item('cookie_prefix'))
+ if ($cookie_prefix = config_item('cookie_prefix'))
{
- $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
+ $this->_csrf_cookie_name = $cookie_prefix.$this->_csrf_cookie_name;
}
// Set the CSRF hash
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 995bf0bbe..1af42ed1f 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -111,7 +111,7 @@ class CI_Encrypt {
$key = config_item('encryption_key');
- if ($key === FALSE)
+ if ( ! strlen($key))
{
show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
}
diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php
index 5c32ca5c2..2e8265b15 100644
--- a/tests/mocks/core/common.php
+++ b/tests/mocks/core/common.php
@@ -32,7 +32,7 @@ if ( ! function_exists('config_item'))
if ( ! isset($config[$item]))
{
- return FALSE;
+ return NULL;
}
return $config[$item];
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a3b354961..0e4930289 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -492,6 +492,7 @@ Release Date: Not Released
- Changed internal function ``load_class()`` to accept a constructor parameter instead of (previously unused) class name prefix.
- Removed default parameter value of :func:`is_php()`.
- Added a second argument ``$double_encode`` to :func:`html_escape()`.
+ - Changed function ``config_item()`` to return NULL instead of FALSE when no value is found.
- :doc:`Output Library <libraries/output>` changes include:
diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst
index 9c0a7cbe1..399a323cc 100644
--- a/user_guide_src/source/general/common_functions.rst
+++ b/user_guide_src/source/general/common_functions.rst
@@ -63,7 +63,7 @@ loading any libraries or helpers.
.. function:: config_item($key)
:param string $key: Config item key
- :returns: Configuration key value or FALSE if not found
+ :returns: Configuration key value or NULL if not found
:rtype: mixed
The :doc:`Config Library <../libraries/config>` is the preferred way of
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 6915fafe2..81340e6ad 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -158,6 +158,10 @@ Step 10: Many functions now return NULL instead of FALSE on missing items
Many methods and functions now return NULL instead of FALSE when the required items don't exist:
+ - :doc:`Common functions <../general/common_functions>`
+
+ - config_item()
+
- :doc:`Config Class <../libraries/config>`
- config->item()