diff --git a/classes/cache/CacheApc.class.php b/classes/cache/CacheApc.class.php index acc2cb45a..a416b1270 100644 --- a/classes/cache/CacheApc.class.php +++ b/classes/cache/CacheApc.class.php @@ -8,6 +8,8 @@ * */ class CacheApc extends CacheBase { + public static $isSupport = false; + /** * Get instance of CacheApc * @@ -30,7 +32,6 @@ class CacheApc extends CacheBase */ function CacheApc() { - } /** @@ -40,7 +41,7 @@ class CacheApc extends CacheBase */ function isSupport() { - return function_exists('apc_add'); + return self::$isSupport; } /** @@ -148,6 +149,10 @@ class CacheApc extends CacheBase return apc_clear_cache('user'); } + } + +CacheApc::$isSupport = function_exists('apc_add'); + /* End of file CacheApc.class.php */ /* Location: ./classes/cache/CacheApc.class.php */ diff --git a/classes/cache/CacheFile.class.php b/classes/cache/CacheFile.class.php index 85210a4ff..f837fd5fa 100644 --- a/classes/cache/CacheFile.class.php +++ b/classes/cache/CacheFile.class.php @@ -6,7 +6,7 @@ * * Filedisk Cache Handler * - * @author Arnia Software (xe_dev@arnia.ro) + * @author NAVER (developers@xpressengine.com) */ class CacheFile extends CacheBase { @@ -90,8 +90,15 @@ class CacheFile extends CacheBase function isValid($key, $modified_time = 0) { $cache_file = $this->getCacheFileName($key); + if(file_exists($cache_file)) { + if($modified_time > 0 && filemtime($cache_file) < $modified_timed) + { + FileHandler::removeFile($cache_file); + return false; + } + return true; } @@ -107,15 +114,19 @@ class CacheFile extends CacheBase */ function get($key, $modified_time = 0) { - $cache_file = FileHandler::exists($this->getCacheFileName($key)); + if(!$cache_file = FileHandler::exists($this->getCacheFileName($key))) + { + return false; + } - if($cache_file) $content = include($cache_file); - - if(!$content) + if($modified_time > 0 && filemtime($cache_file) < $modified_timed) { + FileHandler::removeFile($cache_file); return false; } + $content = include($cache_file); + return unserialize(stripslashes($content)); } diff --git a/classes/cache/CacheMemcache.class.php b/classes/cache/CacheMemcache.class.php index c5d72efba..6869ff838 100644 --- a/classes/cache/CacheMemcache.class.php +++ b/classes/cache/CacheMemcache.class.php @@ -56,10 +56,11 @@ class CacheMemcache extends CacheBase */ function isSupport() { - if($GLOBALS['XE_MEMCACHE_SUPPORT']) + if(isset($GLOBALS['XE_MEMCACHE_SUPPORT'])) { return true; } + if($this->Memcache->set('xe', 'xe', MEMCACHE_COMPRESSED, 1)) { $GLOBALS['XE_MEMCACHE_SUPPORT'] = true; @@ -68,6 +69,7 @@ class CacheMemcache extends CacheBase { $GLOBALS['XE_MEMCACHE_SUPPORT'] = false; } + return $GLOBALS['XE_MEMCACHE_SUPPORT']; } diff --git a/classes/cache/CacheWincache.class.php b/classes/cache/CacheWincache.class.php index 1b393a504..072f968d4 100644 --- a/classes/cache/CacheWincache.class.php +++ b/classes/cache/CacheWincache.class.php @@ -10,6 +10,8 @@ */ class CacheWincache extends CacheBase { + public static $isSupport = false; + /** * Get instance of CacheWincache * @@ -32,7 +34,6 @@ class CacheWincache extends CacheBase */ function CacheWincache() { - } /** @@ -42,7 +43,7 @@ class CacheWincache extends CacheBase */ function isSupport() { - return function_exists('wincache_ucache_set'); + return self::$isSupport; } /** @@ -150,7 +151,8 @@ class CacheWincache extends CacheBase { return wincache_ucache_clear(); } - } + +CacheWincache::$isSupport = function_exists('wincache_ucache_set'); /* End of file CacheWincache.class.php */ /* Location: ./classes/cache/CacheWincache.class.php */ diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index ee9370891..3a9d72b66 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -116,7 +116,7 @@ class TemplateHandler */ public function compile($tpl_path, $tpl_filename, $tpl_file = '') { - $buff = ''; + $buff = false; // store the starting time for debug information if(__DEBUG__ == 3) @@ -159,7 +159,7 @@ class TemplateHandler } } - if(!$buff) + if($buff === FALSE) { $buff = $this->parse(); if($oCacheHandler->isSupport()) diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 4c772ed39..d5f535634 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -442,6 +442,7 @@ class commentModel extends comment } // cache controll + $output = false; $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { @@ -450,7 +451,7 @@ class commentModel extends comment $output = $oCacheHandler->get($cache_key); } - if(!$output) + if($output === FALSE) { // get the number of comments on the document module $oDocumentModel = getModel('document'); diff --git a/modules/counter/counter.model.php b/modules/counter/counter.model.php index 28610f7bd..06e90f190 100644 --- a/modules/counter/counter.model.php +++ b/modules/counter/counter.model.php @@ -8,7 +8,6 @@ */ class counterModel extends counter { - /** * Initialization * @@ -16,7 +15,6 @@ class counterModel extends counter */ function init() { - } /** @@ -32,26 +30,27 @@ class counterModel extends counter $args->ipaddress = $_SERVER['REMOTE_ADDR']; $args->site_srl = $site_srl; + $iplogged = false; $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { $object_key = 'counter:' . $site_srl . '_' . str_replace(array('.', ':'), '-', $args->ipaddress); $cache_key = $oCacheHandler->getGroupKey('counterIpLogged_' . $args->regdate, $object_key); - if($oCacheHandler->isValid($cache_key)) - { - return $oCacheHandler->get($cache_key); - } + $iplogged = $oCacheHandler->get($cache_key); } - $output = executeQuery('counter.getCounterLog', $args); - - $result = $output->data->count ? TRUE : FALSE; - if($result && $oCacheHandler->isSupport()) + if($iplogged === false) { - $oCacheHandler->put($cache_key, TRUE); + $output = executeQuery('counter.getCounterLog', $args); + if($output->data->count) $iplogged = TRUE; } - return $result; + if($iplogged && $oCacheHandler->isSupport()) + { + $oCacheHandler->put($cache_key, $iplogged); + } + + return $iplogged; } /** @@ -65,35 +64,37 @@ class counterModel extends counter $args = new stdClass; $args->regdate = date('Ymd'); + $insertedTodayStatus = false; $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); if($oCacheHandler->isSupport()) { $cache_key = 'counter:insertedTodayStatus:' . $site_srl . '_' . $args->regdate; - if($oCacheHandler->isValid($cache_key)) + $insertedTodayStatus = $oCacheHandler->get($cache_key); + } + + if($insertedTodayStatus === false) + { + if($site_srl) { - return $oCacheHandler->get($cache_key); + $args->site_srl = $site_srl; + $output = executeQuery('counter.getSiteTodayStatus', $args); } + else + { + $output = executeQuery('counter.getTodayStatus', $args); + } + + $insertedTodayStatus = !!$output->data->count; } - if($site_srl) - { - $args->site_srl = $site_srl; - $output = executeQuery('counter.getSiteTodayStatus', $args); - } - else - { - $output = executeQuery('counter.getTodayStatus', $args); - } - - $result = $output->data->count ? TRUE : FALSE; - if($result && $oCacheHandler->isSupport()) + if($insertedTodayStatus && $oCacheHandler->isSupport()) { $oCacheHandler->put($cache_key, TRUE); $_old_date = date('Ymd', strtotime('-1 day')); $oCacheHandler->delete('counter:insertedTodayStatus:' . $site_srl . '_' . $_old_date); } - return $result; + return $insertedTodayStatus; } /** diff --git a/modules/document/document.item.php b/modules/document/document.item.php index f6a7ec3a0..dba7f97fd 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -58,7 +58,8 @@ class documentItem extends Object $this->document_srl = $document_srl; $this->columnList = $columnList; - $this->_loadFromDB($load_extra_vars); + $oDocumentModel = getModel('document'); + if($load_extra_vars === true) $oDocumentModel->getDocumentExtraVarsFromDB($document_srl); } function setDocument($document_srl, $load_extra_vars = true) @@ -76,13 +77,15 @@ class documentItem extends Object { if(!$this->document_srl) return; + $document_item = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { $cache_key = 'document_item:' . $this->document_srl; $document_item = $oCacheHandler->get($cache_key); - if($document_item) + + if($document_item !== false) { $document_item = (object)$document_item->getVariables(); $this->columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); @@ -97,9 +100,10 @@ class documentItem extends Object $args->document_srl = $this->document_srl; $output = executeQuery('document.getDocument', $args, $this->columnList); - if(!$document_item) + if($document_item === false) { - $document_item = $output->data; + if(!is_object($output->data)) $document_item = new stdClass; + else $document_item = $output->data; } else { @@ -139,13 +143,13 @@ class documentItem extends Object } $oDocumentModel = getModel('document'); - $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this; if($load_extra_vars) { - $oDocumentModel->setToAllDocumentExtraVars(); - $this->add('title', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('title')); - $this->add('content', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('content')); + $oDocumentModel->getDocumentExtraVarsFromDB($this->document_srl); + $this->add('title', $this->get('title')); + $this->add('content', $this->get('content')); } + $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this; } function isExists() diff --git a/modules/document/document.model.php b/modules/document/document.model.php index eee8774a7..c570830f8 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -361,8 +361,9 @@ class documentModel extends document */ function getExtraKeys($module_srl) { - if(is_null($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) + if($GLOBALS['XE_EXTRA_KEYS'][$module_srl] === NULL) { + $keys = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -371,8 +372,9 @@ class documentModel extends document $keys = $oCacheHandler->get($cache_key); } - $oExtraVar = &ExtraVar::getInstance($module_srl); - if(!$keys) + $oExtraVar = ExtraVar::getInstance($module_srl); + + if($keys === false) { $obj = new stdClass(); $obj->module_srl = $module_srl; diff --git a/modules/layout/layout.model.php b/modules/layout/layout.model.php index e45cb5922..85e38441a 100644 --- a/modules/layout/layout.model.php +++ b/modules/layout/layout.model.php @@ -258,6 +258,8 @@ class layoutModel extends layout */ function getLayout($layout_srl) { + $layout_info = false; + // cache controll $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) @@ -267,7 +269,7 @@ class layoutModel extends layout $layout_info = $oCacheHandler->get($cache_key); } - if(!$layout_info) + if($layout_info === false) { // Get information from the DB $args = new stdClass(); diff --git a/modules/member/member.model.php b/modules/member/member.model.php index cb4a1156b..ff543158c 100644 --- a/modules/member/member.model.php +++ b/modules/member/member.model.php @@ -295,6 +295,8 @@ class memberModel extends member //columnList size zero... get full member info if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) { + $GLOBALS['__member_info__'][$member_srl] = false; + $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { @@ -304,7 +306,7 @@ class memberModel extends member $GLOBALS['__member_info__'][$member_srl] = $oCacheHandler->get($cache_key); } - if(!$GLOBALS['__member_info__'][$member_srl]) + if($GLOBALS['__member_info__'][$member_srl] === false) { $args = new stdClass(); $args->member_srl = $member_srl; @@ -458,7 +460,10 @@ class memberModel extends member */ function getMemberGroups($member_srl, $site_srl = 0, $force_reload = false) { + static $member_groups = array(); + // cache controll + $group_list = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -467,11 +472,9 @@ class memberModel extends member $group_list = $oCacheHandler->get($cache_key); } - static $member_groups = array(); - if(!$member_groups[$member_srl][$site_srl] || $force_reload) { - if(!$group_list && !is_array($group_list)) + if($group_list === false) { $args = new stdClass(); $args->member_srl = $member_srl; @@ -516,6 +519,7 @@ class memberModel extends member */ function getDefaultGroup($site_srl = 0, $columnList = array()) { + $default_group = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -525,7 +529,7 @@ class memberModel extends member $default_group = $oCacheHandler->get($cache_key); } - if(!$default_group) + if($default_group === false) { $args = new stdClass(); $args->site_srl = $site_srl; @@ -574,6 +578,7 @@ class memberModel extends member $site_srl = 0; } + $group_list = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -581,9 +586,9 @@ class memberModel extends member $cache_key = $oCacheHandler->getGroupKey('member', $object_key); $group_list = $oCacheHandler->get($cache_key); } - if(!$group_list) - { + if($group_list === false) + { $args = new stdClass(); $args->site_srl = $site_srl; $args->sort_index = 'list_order'; diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 12da26c88..64f088e58 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -118,6 +118,7 @@ class moduleModel extends module // If domain is set, look for subsite if($domain !== '') { + $site_info = false; if($oCacheHandler->isSupport()) { $object_key = 'site_info:' . md5($domain); @@ -125,12 +126,13 @@ class moduleModel extends module $site_info = $oCacheHandler->get($domain_cache_key); } - if(!$site_info) + if($site_info === false) { $args = new stdClass(); $args->domain = $domain; $output = executeQuery('module.getSiteInfoByDomain', $args); $site_info = $output->data; + if($oCacheHandler->isSupport()) $oCacheHandler->put($domain_cache_key, $site_info); } @@ -145,14 +147,15 @@ class moduleModel extends module // If no virtual website was found, get default website if($domain === '') { + $site_info = false; if($oCacheHandler->isSupport()) { $object_key = 'default_site'; $default_site_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); - $module_info = $oCacheHandler->get($default_site_cache_key); + $site_info = $oCacheHandler->get($default_site_cache_key); } - if(!$site_info) + if($site_info === false) { $args = new stdClass(); $args->site_srl = 0; @@ -212,6 +215,10 @@ class moduleModel extends module $args = new stdClass(); $args->mid = $mid; $args->site_srl = (int)$site_srl; + + $module_srl = false; + $module_info = false; + $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -226,7 +233,7 @@ class moduleModel extends module } } - if(!$module_info && !is_array($module_info)) + if($module_info === false) { $output = executeQuery('module.getMidInfo', $args); $module_info = $output->data; @@ -310,6 +317,9 @@ class moduleModel extends module $moduleInfo->designSettings->skin->mobileIsDefault = $moduleInfo->is_mskin_fix == 'N' ? 1 : 0; $moduleInfo->designSettings->skin->mobile = $skinInfoMobile->title; + $module_srl = false; + $mid_info = false; + $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -320,10 +330,10 @@ class moduleModel extends module { $object_key = 'mid_info:' . $module_srl; $module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); - $coutput = $oCacheHandler->get($module_info_cache_key); + $mid_info = $oCacheHandler->get($module_info_cache_key); } - if(!$coutput) + if($mid_info === false) { $oCacheHandler->put($module_srl_cache_key, $output->data->module_srl); @@ -333,8 +343,8 @@ class moduleModel extends module } else { - $coutput->designSettings = $moduleInfo->designSettings; - $moduleInfo = $coutput; + $mid_info->designSettings = $moduleInfo->designSettings; + $moduleInfo = $mid_info; } } @@ -356,9 +366,8 @@ class moduleModel extends module */ function getModuleInfoByModuleSrl($module_srl, $columnList = array()) { - // Get data - $args = new stdClass(); - $args->module_srl = $module_srl; + $mid_info = false; + $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -367,8 +376,11 @@ class moduleModel extends module $mid_info = $oCacheHandler->get($cache_key); } - if(!$mid_info && !is_array($mid_info)) + if($mid_info === false) { + // Get data + $args = new stdClass(); + $args->module_srl = $module_srl; $output = executeQuery('module.getMidInfo', $args); if(!$output->toBool()) return; @@ -482,6 +494,7 @@ class moduleModel extends module */ function getMidList($args = null, $columnList = array()) { + $list = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -493,7 +506,7 @@ class moduleModel extends module } } - if(!$list) + if($list === false) { if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl)) { @@ -517,6 +530,7 @@ class moduleModel extends module { $mid_list[$val->mid] = $val; } + return $mid_list; } @@ -567,6 +581,7 @@ class moduleModel extends module */ function getActionForward($act) { + $action_forward = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); if($oCacheHandler->isSupport()) @@ -576,7 +591,7 @@ class moduleModel extends module } // retrieve and caching all registered action_forward - if(!$action_forward) + if($action_forward === false) { $args = new stdClass(); $output = executeQueryArray('module.getActionForward',$args); @@ -589,20 +604,19 @@ class moduleModel extends module $action_forward[$item->act] = $item; } - if($oCacheHandler->isSupport()) { $oCacheHandler->put($cache_key, $action_forward); } } - + if($action_forward[$act]) { return $action_forward[$act]; } else { - return new stdClass(); + return new stdClass(); } } @@ -611,6 +625,7 @@ class moduleModel extends module */ function getTriggers($trigger_name, $called_position) { + $triggers = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); if($oCacheHandler->isSupport()) @@ -620,7 +635,7 @@ class moduleModel extends module $triggers = $oCacheHandler->get($cache_key); } - if(!$triggers && !is_array($triggers)) + if($triggers === false) { $args = new stdClass(); $args->trigger_name = $trigger_name; @@ -1336,6 +1351,7 @@ class moduleModel extends module */ function getModuleConfig($module, $site_srl = 0) { + $config = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) @@ -1344,15 +1360,17 @@ class moduleModel extends module $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); $config = $oCacheHandler->get($cache_key); } - if(!$config) + + if($config === false) { - if(!$GLOBALS['__ModuleConfig__'][$site_srl][$module]) + if(!isset($GLOBALS['__ModuleConfig__'][$site_srl][$module])) { $args = new stdClass(); $args->module = $module; $args->site_srl = $site_srl; $output = executeQuery('module.getModuleConfig', $args); $config = unserialize($output->data->config); + if(!$config) $config = new stdClass; //insert in cache if($oCacheHandler->isSupport()) @@ -1373,6 +1391,7 @@ class moduleModel extends module */ function getModulePartConfig($module, $module_srl) { + $config = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) @@ -1381,15 +1400,17 @@ class moduleModel extends module $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); $config = $oCacheHandler->get($cache_key); } - if(!$config) + + if($config === false) { - if(!$GLOBALS['__ModulePartConfig__'][$module][$module_srl]) + if(!isset($GLOBALS['__ModulePartConfig__'][$module][$module_srl])) { $args = new stdClass(); $args->module = $module; $args->module_srl = $module_srl; $output = executeQuery('module.getModulePartConfig', $args); $config = unserialize($output->data->config); + if(!$config) $config = new stdClass; //insert in cache if($oCacheHandler->isSupport()) @@ -1690,6 +1711,7 @@ class moduleModel extends module $get_module_srls = array(); if(!is_array($list_module_srl)) $list_module_srl = array($list_module_srl); + $vars = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) @@ -1715,7 +1737,7 @@ class moduleModel extends module $get_module_srls = $list_module_srl; } - if(count($get_module_srls)) + if($vars === false || count($get_module_srls) > 0) { $args = new stdClass(); $args->module_srl = implode(',', $get_module_srls); @@ -1760,6 +1782,7 @@ class moduleModel extends module */ function getModuleSkinVars($module_srl) { + $skin_vars = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -1768,7 +1791,7 @@ class moduleModel extends module $skin_vars = $oCacheHandler->get($cache_key); } - if(!$skin_vars) + if($skin_vars === false) { $args = new stdClass(); $args->module_srl = $module_srl; @@ -1874,6 +1897,7 @@ class moduleModel extends module */ function getModuleMobileSkinVars($module_srl) { + $skin_vars = false; $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) { @@ -1882,7 +1906,7 @@ class moduleModel extends module $skin_vars = $oCacheHandler->get($cache_key); } - if(!$skin_vars) + if($skin_vars === false) { $args = new stdClass(); $args->module_srl = $module_srl; @@ -1908,6 +1932,7 @@ class moduleModel extends module function syncMobileSkinInfoToModuleInfo(&$module_info) { if(!$module_info->module_srl) return; + $skin_vars = false; // cache controll $oCacheHandler = CacheHandler::getInstance('object', null, true); if($oCacheHandler->isSupport()) @@ -1916,7 +1941,7 @@ class moduleModel extends module $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); $skin_vars = $oCacheHandler->get($cache_key); } - if(!$skin_vars) + if($skin_vars === false) { $args = new stdClass; $args->module_srl = $module_info->module_srl; diff --git a/modules/session/session.controller.php b/modules/session/session.controller.php index 1a5bd6e14..2015ac688 100644 --- a/modules/session/session.controller.php +++ b/modules/session/session.controller.php @@ -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; } diff --git a/modules/session/session.model.php b/modules/session/session.model.php index ee5a2936a..694f3bc52 100644 --- a/modules/session/session.model.php +++ b/modules/session/session.model.php @@ -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; }