summaryrefslogtreecommitdiff
path: root/system/libraries/drivers/Session
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-11-24 19:20:36 -0800
committerBharat Mediratta <bharat@menalto.com>2009-11-24 19:20:36 -0800
commit9b6663f87a7e679ffba691cf516191fc840cf978 (patch)
tree20cf9f3aaf93b4ba69d282dcf10d259db4a752de /system/libraries/drivers/Session
parent82ee5f9d338017c69331b2907f37a468ced8c66e (diff)
Update to Kohana r4684 which is now Kohana 2.4 and has substantial
changes.
Diffstat (limited to 'system/libraries/drivers/Session')
-rw-r--r--system/libraries/drivers/Session/Cache.php10
-rw-r--r--system/libraries/drivers/Session/Cookie.php10
-rw-r--r--system/libraries/drivers/Session/Database.php40
3 files changed, 36 insertions, 24 deletions
diff --git a/system/libraries/drivers/Session/Cache.php b/system/libraries/drivers/Session/Cache.php
index 45e49495..c0d4d0a4 100644
--- a/system/libraries/drivers/Session/Cache.php
+++ b/system/libraries/drivers/Session/Cache.php
@@ -10,12 +10,12 @@
* Lifetime does not need to be set as it is
* overridden by the session expiration setting.
*
- * $Id: Cache.php 4431 2009-07-01 03:41:41Z kiall $
+ * $Id: Cache.php 4679 2009-11-10 01:45:52Z isaiah $
*
* @package Core
* @author Kohana Team
- * @copyright (c) 2007-2008 Kohana Team
- * @license http://kohanaphp.com/license.html
+ * @copyright (c) 2007-2009 Kohana Team
+ * @license http://kohanaphp.com/license
*/
class Session_Cache_Driver implements Session_Driver {
@@ -30,7 +30,7 @@ class Session_Cache_Driver implements Session_Driver {
$this->encrypt = new Encrypt;
}
- Kohana::log('debug', 'Session Cache Driver Initialized');
+ Kohana_Log::add('debug', 'Session Cache Driver Initialized');
}
public function open($path, $name)
@@ -48,7 +48,7 @@ class Session_Cache_Driver implements Session_Driver {
// Test the config group name
if (($config = Kohana::config('cache.'.$config)) === NULL)
- throw new Kohana_Exception('cache.undefined_group', $name);
+ throw new Kohana_Exception('The :group: group is not defined in your configuration.', array(':group:' => $name));
}
$config['lifetime'] = (Kohana::config('session.expiration') == 0) ? 86400 : Kohana::config('session.expiration');
diff --git a/system/libraries/drivers/Session/Cookie.php b/system/libraries/drivers/Session/Cookie.php
index 4cf18fc2..ef575cab 100644
--- a/system/libraries/drivers/Session/Cookie.php
+++ b/system/libraries/drivers/Session/Cookie.php
@@ -2,12 +2,12 @@
/**
* Session cookie driver.
*
- * $Id: Cookie.php 4431 2009-07-01 03:41:41Z kiall $
+ * $Id: Cookie.php 4679 2009-11-10 01:45:52Z isaiah $
*
* @package Core
* @author Kohana Team
- * @copyright (c) 2007-2008 Kohana Team
- * @license http://kohanaphp.com/license.html
+ * @copyright (c) 2007-2009 Kohana Team
+ * @license http://kohanaphp.com/license
*/
class Session_Cookie_Driver implements Session_Driver {
@@ -23,7 +23,7 @@ class Session_Cookie_Driver implements Session_Driver {
$this->encrypt = Encrypt::instance();
}
- Kohana::log('debug', 'Session Cookie Driver Initialized');
+ Kohana_Log::add('debug', 'Session Cookie Driver Initialized');
}
public function open($path, $name)
@@ -55,7 +55,7 @@ class Session_Cookie_Driver implements Session_Driver {
if (strlen($data) > 4048)
{
- Kohana::log('error', 'Session ('.$id.') data exceeds the 4KB limit, ignoring write.');
+ Kohana_Log::add('error', 'Session ('.$id.') data exceeds the 4KB limit, ignoring write.');
return FALSE;
}
diff --git a/system/libraries/drivers/Session/Database.php b/system/libraries/drivers/Session/Database.php
index 490875a1..cbe76001 100644
--- a/system/libraries/drivers/Session/Database.php
+++ b/system/libraries/drivers/Session/Database.php
@@ -2,12 +2,12 @@
/**
* Session database driver.
*
- * $Id: Database.php 4431 2009-07-01 03:41:41Z kiall $
+ * $Id: Database.php 4679 2009-11-10 01:45:52Z isaiah $
*
* @package Core
* @author Kohana Team
- * @copyright (c) 2007-2008 Kohana Team
- * @license http://kohanaphp.com/license.html
+ * @copyright (c) 2007-2009 Kohana Team
+ * @license http://kohanaphp.com/license
*/
class Session_Database_Driver implements Session_Driver {
@@ -58,10 +58,7 @@ class Session_Database_Driver implements Session_Driver {
}
}
- // Load database
- $this->db = Database::instance($this->db);
-
- Kohana::log('debug', 'Session Database Driver Initialized');
+ Kohana_Log::add('debug', 'Session Database Driver Initialized');
}
public function open($path, $name)
@@ -77,7 +74,11 @@ class Session_Database_Driver implements Session_Driver {
public function read($id)
{
// Load the session
- $query = $this->db->from($this->table)->where('session_id', $id)->limit(1)->get()->result(TRUE);
+ $query = db::select('data')
+ ->from($this->table)
+ ->where('session_id', '=', $id)
+ ->limit(1)
+ ->execute($this->db);
if ($query->count() === 0)
{
@@ -111,7 +112,8 @@ class Session_Database_Driver implements Session_Driver {
if ($this->session_id === NULL)
{
// Insert a new session
- $query = $this->db->insert($this->table, $data);
+ $query = db::insert($this->table, $data)
+ ->execute($this->db);
}
elseif ($id === $this->session_id)
{
@@ -119,12 +121,18 @@ class Session_Database_Driver implements Session_Driver {
unset($data['session_id']);
// Update the existing session
- $query = $this->db->update($this->table, $data, array('session_id' => $id));
+ $query = db::update($this->table)
+ ->set($data)
+ ->where('session_id', '=', $id)
+ ->execute($this->db);
}
else
{
// Update the session and id
- $query = $this->db->update($this->table, $data, array('session_id' => $this->session_id));
+ $query = db::update($this->table)
+ ->set($data)
+ ->where('session_id', '=', $this->session_id)
+ ->execute($this->db);
// Set the new session id
$this->session_id = $id;
@@ -136,7 +144,9 @@ class Session_Database_Driver implements Session_Driver {
public function destroy($id)
{
// Delete the requested session
- $this->db->delete($this->table, array('session_id' => $id));
+ db::delete($this->table)
+ ->where('session_id', '=', $id)
+ ->execute($this->db);
// Session id is no longer valid
$this->session_id = NULL;
@@ -156,9 +166,11 @@ class Session_Database_Driver implements Session_Driver {
public function gc($maxlifetime)
{
// Delete all expired sessions
- $query = $this->db->delete($this->table, array('last_activity <' => time() - $maxlifetime));
+ $query = db::delete($this->table)
+ ->where('last_activity', '<', time() - $maxlifetime)
+ ->execute($this->db);
- Kohana::log('debug', 'Session garbage collected: '.$query->count().' row(s) deleted.');
+ Kohana_Log::add('debug', 'Session garbage collected: '.$query->count().' row(s) deleted.');
return TRUE;
}