diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-21 14:11:25 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-21 14:14:02 +0400 |
commit | 1a982d8a5416e15d36b16145d9ec599d49eb755a (patch) | |
tree | 71b320d3d02268506b8351522e838ccd3bd97f7c | |
parent | e09d673cc2fe77f45c47507bc6f988ab21458cb7 (diff) |
Get Db connection singleton in DbTable session handler upon use instead of storing the connection upon creation.
-rw-r--r-- | core/Session.php | 3 | ||||
-rw-r--r-- | core/Session/SaveHandler/DbTable.php | 11 |
2 files changed, 6 insertions, 8 deletions
diff --git a/core/Session.php b/core/Session.php index 7109dd0db2..787affe29d 100644 --- a/core/Session.php +++ b/core/Session.php @@ -89,15 +89,12 @@ class Session extends Zend_Session // - user - we can't verify that user-defined session handler functions have already been set via session_set_save_handler() // - mm - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue - $db = Db::get(); - $config = array( 'name' => Common::prefixTable('session'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', - 'db' => $db, ); $saveHandler = new DbTable($config); diff --git a/core/Session/SaveHandler/DbTable.php b/core/Session/SaveHandler/DbTable.php index 8521215c9b..20494fe98e 100644 --- a/core/Session/SaveHandler/DbTable.php +++ b/core/Session/SaveHandler/DbTable.php @@ -9,6 +9,7 @@ namespace Piwik\Session\SaveHandler; +use Piwik\Db; use Zend_Session; use Zend_Session_SaveHandler_Interface; @@ -49,7 +50,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface */ public function open($save_path, $name) { - $this->config['db']->getConnection(); + Db::get()->getConnection(); return true; } @@ -76,7 +77,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface . ' WHERE ' . $this->config['primary'] . ' = ?' . ' AND ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' >= ?'; - $result = $this->config['db']->fetchOne($sql, array($id, time())); + $result = Db::get()->fetchOne($sql, array($id, time())); if (!$result) $result = ''; @@ -103,7 +104,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface . $this->config['lifetimeColumn'] . ' = ?,' . $this->config['dataColumn'] . ' = ?'; - $this->config['db']->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data)); + Db::get()->query($sql, array($id, time(), $this->maxLifetime, $data, time(), $this->maxLifetime, $data)); return true; } @@ -120,7 +121,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface $sql = 'DELETE FROM ' . $this->config['name'] . ' WHERE ' . $this->config['primary'] . ' = ?'; - $this->config['db']->query($sql, array($id)); + Db::get()->query($sql, array($id)); return true; } @@ -137,7 +138,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface $sql = 'DELETE FROM ' . $this->config['name'] . ' WHERE ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' < ?'; - $this->config['db']->query($sql, array(time())); + Db::get()->query($sql, array(time())); return true; } |