mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
fix #385 object cache 정리 및 오류가 발생할 수 는 문제 해결
This commit is contained in:
parent
58e141c48a
commit
d48d9d80a7
14 changed files with 175 additions and 167 deletions
|
|
@ -27,32 +27,22 @@ class sessionController extends session
|
|||
function write($session_key, $val)
|
||||
{
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
$oCacheHandler = CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$cache_vars = $oCacheHandler->get($cache_key);
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->session_key = $session_key;
|
||||
if($cache_vars) $session_info = $cache_vars;
|
||||
else
|
||||
{
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
$session_info = $output->data;
|
||||
}
|
||||
//if ip has changed delete the session from cache and db
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
$session_info = $output->data;
|
||||
|
||||
//if ip has changed delete the session from db
|
||||
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR'])
|
||||
{
|
||||
if($oCacheHandler->isSupport()) $oCacheHandler->delete($cache_key);
|
||||
executeQuery('session.deleteSession', $args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$args->expired = date("YmdHis", $_SERVER['REQUEST_TIME']+$this->lifetime);
|
||||
$args->expired = date("YmdHis", $_SERVER['REQUEST_TIME'] + $this->lifetime);
|
||||
$args->val = $val;
|
||||
$args->cur_mid = Context::get('mid');
|
||||
|
||||
if(!$args->cur_mid)
|
||||
{
|
||||
$module_info = Context::get('current_module_info');
|
||||
|
|
@ -70,43 +60,15 @@ class sessionController extends session
|
|||
}
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
$args->last_update = date("YmdHis", $_SERVER['REQUEST_TIME']);
|
||||
$diff = $args->last_update - $cache_vars->last_update;
|
||||
//verify if session values have changed
|
||||
if($val == $cache_vars->val)
|
||||
|
||||
//put session into db
|
||||
if($session_info->session_key)
|
||||
{
|
||||
// if more than 5 minutes passed than modify the db session also
|
||||
if($diff > 300)
|
||||
{
|
||||
//put session into cache
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$oCacheHandler->put($cache_key,$args,$this->lifetime);
|
||||
}
|
||||
//put session into db
|
||||
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
//put session into cache
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$oCacheHandler->put($cache_key,$args,$this->lifetime);
|
||||
}
|
||||
}
|
||||
$output = executeQuery('session.updateSession', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
//put session into cache
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$oCacheHandler->put($cache_key,$args,$this->lifetime);
|
||||
}
|
||||
//put session into db
|
||||
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
||||
else $output = executeQuery('session.insertSession', $args);
|
||||
$output = executeQuery('session.insertSession', $args);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -115,17 +77,12 @@ class sessionController extends session
|
|||
function destroy($session_key)
|
||||
{
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
//remove session from cache
|
||||
$oCacheHandler = CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
|
||||
//remove session from db
|
||||
$args = new stdClass();
|
||||
$args->session_key = $session_key;
|
||||
executeQuery('session.deleteSession', $args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,36 +23,27 @@ class sessionModel extends session
|
|||
{
|
||||
if(!$session_key || !$this->session_started) return;
|
||||
|
||||
$output = new Object();
|
||||
$args = new stdClass();
|
||||
$args->session_key = $session_key;
|
||||
$columnList = array('session_key', 'cur_mid', 'val');
|
||||
$output = executeQuery('session.getSession', $args, $columnList);
|
||||
|
||||
$oCacheHandler = CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
// Confirm there is a table created if read error occurs
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$cache_key = 'session:'.$session_key;
|
||||
$output->data = $oCacheHandler->get($cache_key);
|
||||
$oDB = DB::getInstance();
|
||||
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
||||
if(!$oDB->isColumnExists("session", "cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
}
|
||||
|
||||
if(!$output->data)
|
||||
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
|
||||
if(!isset($output->data->cur_mid))
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->session_key = $session_key;
|
||||
$columnList = array('session_key', 'cur_mid', 'val');
|
||||
$output = executeQuery('session.getSession', $args, $columnList);
|
||||
// Confirm there is a table created if read error occurs
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
||||
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||
$output = executeQuery('session.getSession', $args);
|
||||
}
|
||||
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
|
||||
if(!isset($output->data->cur_mid))
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||
}
|
||||
$oDB = DB::getInstance();
|
||||
if(!$oDB->isColumnExists("session", "cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||
}
|
||||
|
||||
return $output->data->val;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue