summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchill42 <dchill42@gmail.com>2012-07-30 20:53:11 +0200
committerdchill42 <dchill42@gmail.com>2012-07-30 20:53:11 +0200
commitc58722535e0358367f351c168480ef98a033264c (patch)
tree1c9de313b982c4e1c7052a2f3ba827af3e40ec64
parent77ee3fdac34d317b600a269e0b845588c88fa4c5 (diff)
Fixed _parent references and several minor bugs
-rw-r--r--system/libraries/Driver.php2
-rwxr-xr-xsystem/libraries/Session/Session.php14
-rwxr-xr-xsystem/libraries/Session/drivers/Session_cookie.php30
-rwxr-xr-xsystem/libraries/Session/drivers/Session_native.php2
4 files changed, 35 insertions, 13 deletions
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 86b233a15..1d084c8e4 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -65,7 +65,7 @@ class CI_Driver_Library {
public function __get($child)
{
// Try to load the driver
- return load_driver($child);
+ return $this->load_driver($child);
}
/**
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index 9c887d88e..734334249 100755
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -64,7 +64,7 @@ class CI_Session extends CI_Driver_Library {
// Get valid drivers list
$CI =& get_instance();
- $this->valid_drivers = array('CI_Session_native', 'CI_Session_cookie');
+ $this->valid_drivers = array('Session_native', 'Session_cookie');
$key = 'sess_valid_drivers';
$drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
if ($drivers)
@@ -131,7 +131,7 @@ class CI_Session extends CI_Driver_Library {
public function select_driver($driver)
{
// Validate driver name
- $lowername = strtolower($driver);
+ $lowername = strtolower(str_replace('CI_', '', $driver));
if (in_array($lowername, array_map('strtolower', $this->valid_drivers)))
{
// See if regular or lowercase variant is loaded
@@ -177,11 +177,11 @@ class CI_Session extends CI_Driver_Library {
* Fetch a specific item from the session array
*
* @param string Item key
- * @return string Item value
+ * @return string Item value or NULL if not found
*/
public function userdata($item)
{
- // Return value or FALSE if not found
+ // Return value or NULL if not found
return ( ! isset($this->userdata[$item])) ? NULL : $this->userdata[$item];
}
@@ -208,7 +208,7 @@ class CI_Session extends CI_Driver_Library {
// loop through all userdata
foreach ($this->all_userdata() as $key => $val)
{
- // if it contains flashdata, add it
+ // if it contains flashdata, add it
if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE)
{
$out[$key] = $val;
@@ -543,7 +543,7 @@ abstract class CI_Session_driver extends CI_Driver {
// Call base class decorate first
parent::decorate($parent);
- // Call initialize method now that driver has access to $this->parent
+ // Call initialize method now that driver has access to $this->_parent
$this->initialize();
}
@@ -559,7 +559,7 @@ abstract class CI_Session_driver extends CI_Driver {
public function __call($method, $args = array())
{
// Make sure the parent library uses this driver
- $this->parent->select_driver(get_class($this));
+ $this->_parent->select_driver(get_class($this));
return parent::__call($method, $args);
}
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index e39ada052..19ccd417d 100755
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -190,13 +190,13 @@ class CI_Session_cookie extends CI_Session_driver {
'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix',
'encryption_key') as $key)
{
- $this->$key = isset($this->parent->params[$key]) ? $this->parent->params[$key] :
+ $this->$key = isset($this->_parent->params[$key]) ? $this->_parent->params[$key] :
$this->CI->config->item($key);
}
if ($this->encryption_key === '')
{
- show_error('In order to use the Session Cookie driver you are required to set an encryption key '.
+ show_error('In order to use the Cookie Session driver you are required to set an encryption key '.
'in your config file.');
}
@@ -309,7 +309,7 @@ class CI_Session_cookie extends CI_Session_driver {
}
// Kill the cookie
- setcookie($this->sess_cookie_name, addslashes(serialize(array())), ($this->now - 31500000),
+ $this->_setcookie($this->sess_cookie_name, addslashes(serialize(array())), ($this->now - 31500000),
$this->cookie_path, $this->cookie_domain, 0);
// Kill session data
@@ -632,11 +632,33 @@ class CI_Session_cookie extends CI_Session_driver {
$expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
// Set the cookie
- setcookie($this->sess_cookie_name, $cookie_data, $expire, $this->cookie_path, $this->cookie_domain,
+ $this->_setcookie($this->sess_cookie_name, $cookie_data, $expire, $this->cookie_path, $this->cookie_domain,
$this->cookie_secure, $this->cookie_httponly);
}
/**
+ * Set a cookie with the system
+ *
+ * This abstraction of the setcookie call allows overriding for unit testing
+ *
+ * @access protected
+ * @param string Cookie name
+ * @param string Cookie value
+ * @param int Expiration time
+ * @param string Cookie path
+ * @param string Cookie domain
+ * @param bool Secure connection flag
+ * @param bool HTTP protocol only flag
+ * @return void
+ */
+ protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = false,
+ $httponly = false)
+ {
+ // Set the cookie
+ setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
+ }
+
+ /**
* Serialize an array
*
* This function first converts any slashes found in the array to a temporary
diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php
index 8388e06b5..27db942eb 100755
--- a/system/libraries/Session/drivers/Session_native.php
+++ b/system/libraries/Session/drivers/Session_native.php
@@ -39,7 +39,7 @@ class CI_Session_native extends CI_Session_driver {
foreach (array('sess_cookie_name', 'sess_expire_on_close', 'sess_expiration', 'sess_match_ip',
'sess_match_useragent', 'cookie_prefix', 'cookie_path', 'cookie_domain') as $key)
{
- $config[$key] = isset($this->parent->params[$key]) ? $this->parent->params[$key] : $CI->config->item($key);
+ $config[$key] = isset($this->_parent->params[$key]) ? $this->_parent->params[$key] : $CI->config->item($key);
}
// Set session name, if specified