Skip to content

Commit 850b1d6

Browse files
author
a.anokhin
committed
Using lmb_env for session startup filter & session db storage
1 parent f167e1e commit 850b1d6

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

session/src/lmbSessionDbStorage.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ class lmbSessionDbStorage implements lmbSessionStorage
3434
/**
3535
* Constructor.
3636
* @param lmbDbConnection database connection object
37-
* @param integer maximum session life time
3837
*/
39-
function __construct($db_connection, $max_life_time = null)
38+
function __construct($db_connection)
4039
{
40+
$max_life_time = lmb_env_get('LIMB_SESSION_DB_MAX_LIFE_TIME');
41+
4142
$this->max_life_time = $max_life_time;
4243

4344
$this->db = new lmbSimpleDb($db_connection);

session/tests/cases/lmbSessionDbStorageTest.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
/*
33
* Limb PHP Framework
44
*
5-
* @link http://limb-project.com
5+
* @link http://limb-project.com
66
* @copyright Copyright © 2004-2009 BIT(http://bit-creative.com)
7-
* @license LGPL http://www.gnu.org/copyleft/lesser.html
7+
* @license LGPL http://www.gnu.org/copyleft/lesser.html
88
*/
99
lmb_require('limb/session/src/lmbSessionDbStorage.class.php');
1010
lmb_require('limb/dbal/src/lmbSimpleDb.class.php');
@@ -183,7 +183,8 @@ function testStorageGcTrue()
183183

184184
function testStorageGcUseSettedMaxLifeTime()
185185
{
186-
$driver = new lmbSessionDbStorage($this->conn, $max_life_time = 500);
186+
lmb_env_setor('LIMB_SESSION_DB_MAX_LIFE_TIME', 500);
187+
$driver = new lmbSessionDbStorage($this->conn);
187188

188189
$this->db->insert('lmb_session',
189190
array('session_id' => "whatever",

web_app/src/filter/lmbSessionStartupFilter.class.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class lmbSessionStartupFilter implements lmbInterceptingFilter
2929
*/
3030
function run($filter_chain)
3131
{
32-
$session_in_db = defined('LIMB_SESSION_USE_DB_DRIVER') ? LIMB_SESSION_USE_DB_DRIVER : false;
32+
$session_in_db = lmb_env_get('LIMB_SESSION_USE_DB_DRIVER', false);
33+
3334
if($session_in_db)
3435
$storage = $this->_createDBSessionStorage();
3536
else
@@ -53,11 +54,9 @@ protected function _createNativeSessionStorage()
5354
*/
5455
protected function _createDBSessionStorage()
5556
{
56-
$lifetime = defined('LIMB_SESSION_DB_MAX_LIFE_TIME') ? LIMB_SESSION_DB_MAX_LIFE_TIME : null;
57-
5857
lmb_require('limb/session/src/lmbSessionDbStorage.class.php');
5958
$db_connection = lmbToolkit :: instance()->getDefaultDbConnection();
60-
return new lmbSessionDbStorage($db_connection, $lifetime);
59+
return new lmbSessionDbStorage($db_connection);
6160
}
6261
}
6362

0 commit comments

Comments
 (0)