diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-12-26 11:24:50 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-12-26 11:24:50 -0800 |
commit | 3060a6f662da66008d57a461bf1c9b5b4aa2b002 (patch) | |
tree | 442fd290505817efc0324f2af6e01805cb7396aa /system/libraries/drivers/Session | |
parent | 1cd6a615bb47a33794e4a4f690c87a348ab752d7 (diff) | |
parent | 32d25dafd5b033338b6a9bb8c7c53edab462543a (diff) |
Merge branch 'master' into talmdal_dev
Conflicts:
modules/gallery/controllers/albums.php
modules/gallery/controllers/movies.php
modules/gallery/controllers/photos.php
Diffstat (limited to 'system/libraries/drivers/Session')
-rw-r--r-- | system/libraries/drivers/Session/Cache.php | 10 | ||||
-rw-r--r-- | system/libraries/drivers/Session/Cookie.php | 10 | ||||
-rw-r--r-- | system/libraries/drivers/Session/Database.php | 40 |
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; } |