summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/drivers/Session_database_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries/Session/drivers/Session_database_driver.php')
-rw-r--r--system/libraries/Session/drivers/Session_database_driver.php85
1 files changed, 42 insertions, 43 deletions
diff --git a/system/libraries/Session/drivers/Session_database_driver.php b/system/libraries/Session/drivers/Session_database_driver.php
index 734fe624f..89afe3455 100644
--- a/system/libraries/Session/drivers/Session_database_driver.php
+++ b/system/libraries/Session/drivers/Session_database_driver.php
@@ -130,7 +130,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
{
if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
{
- return $this->_fail();
+ return $this->_failure;
}
$this->php5_validate_id();
@@ -150,48 +150,47 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
*/
public function read($session_id)
{
- if ($this->_get_lock($session_id) !== FALSE)
+ if ($this->_get_lock($session_id) === FALSE)
{
- // Prevent previous QB calls from messing with our queries
- $this->_db->reset_query();
-
- // Needed by write() to detect session_regenerate_id() calls
- $this->_session_id = $session_id;
+ return $this->_failure;
+ }
- $this->_db
- ->select('data')
- ->from($this->_config['save_path'])
- ->where('id', $session_id);
+ // Prevent previous QB calls from messing with our queries
+ $this->_db->reset_query();
- if ($this->_config['match_ip'])
- {
- $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
- }
+ // Needed by write() to detect session_regenerate_id() calls
+ $this->_session_id = $session_id;
- if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
- {
- // PHP7 will reuse the same SessionHandler object after
- // ID regeneration, so we need to explicitly set this to
- // FALSE instead of relying on the default ...
- $this->_row_exists = FALSE;
- $this->_fingerprint = md5('');
- return '';
- }
+ $this->_db
+ ->select('data')
+ ->from($this->_config['save_path'])
+ ->where('id', $session_id);
- // PostgreSQL's variant of a BLOB datatype is Bytea, which is a
- // PITA to work with, so we use base64-encoded data in a TEXT
- // field instead.
- $result = ($this->_platform === 'postgre')
- ? base64_decode(rtrim($result->data))
- : $result->data;
+ if ($this->_config['match_ip'])
+ {
+ $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
+ }
- $this->_fingerprint = md5($result);
- $this->_row_exists = TRUE;
- return $result;
+ if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
+ {
+ // PHP7 will reuse the same SessionHandler object after
+ // ID regeneration, so we need to explicitly set this to
+ // FALSE instead of relying on the default ...
+ $this->_row_exists = FALSE;
+ $this->_fingerprint = md5('');
+ return '';
}
- $this->_fingerprint = md5('');
- return '';
+ // PostgreSQL's variant of a BLOB datatype is Bytea, which is a
+ // PITA to work with, so we use base64-encoded data in a TEXT
+ // field instead.
+ $result = ($this->_platform === 'postgre')
+ ? base64_decode(rtrim($result->data))
+ : $result->data;
+
+ $this->_fingerprint = md5($result);
+ $this->_row_exists = TRUE;
+ return $result;
}
// ------------------------------------------------------------------------
@@ -215,7 +214,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
{
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
{
- return $this->_fail();
+ return $this->_failure;
}
$this->_row_exists = FALSE;
@@ -223,7 +222,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
}
elseif ($this->_lock === FALSE)
{
- return $this->_fail();
+ return $this->_failure;
}
if ($this->_row_exists === FALSE)
@@ -242,7 +241,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
return $this->_success;
}
- return $this->_fail();
+ return $this->_failure;
}
$this->_db->where('id', $session_id);
@@ -265,7 +264,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
return $this->_success;
}
- return $this->_fail();
+ return $this->_failure;
}
// ------------------------------------------------------------------------
@@ -280,7 +279,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
public function close()
{
return ($this->_lock && ! $this->_release_lock())
- ? $this->_fail()
+ ? $this->_failure
: $this->_success;
}
@@ -309,7 +308,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
if ( ! $this->_db->delete($this->_config['save_path']))
{
- return $this->_fail();
+ return $this->_failure;
}
}
@@ -319,7 +318,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
return $this->_success;
}
- return $this->_fail();
+ return $this->_failure;
}
// ------------------------------------------------------------------------
@@ -339,7 +338,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
return ($this->_db->delete($this->_config['save_path'], 'timestamp < '.(time() - $maxlifetime)))
? $this->_success
- : $this->_fail();
+ : $this->_failure;
}
// --------------------------------------------------------------------