Merge branch 'feature/object-cache' into develop

This commit is contained in:
bnu 2014-01-08 13:42:18 +09:00
commit 2bd745b627
26 changed files with 701 additions and 454 deletions

View file

@ -8,13 +8,6 @@
* */
class CacheApc extends CacheBase
{
/**
* Default valid time
* @var int
*/
var $valid_time = 36000;
/**
* Get instance of CacheApc
*

View file

@ -10,13 +10,6 @@
*/
class CacheFile extends CacheBase
{
/**
* Default valid time
* @var int
*/
var $valid_time = 36000;
/**
* Path that value to stored
* @var string
@ -56,7 +49,7 @@ class CacheFile extends CacheBase
*/
function getCacheFileName($key)
{
return $this->cache_dir . str_replace(':', '_', $key);
return $this->cache_dir . str_replace(':', '/', $key) . '.php';
}
/**
@ -80,8 +73,11 @@ class CacheFile extends CacheBase
function put($key, $obj, $valid_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$text = serialize($obj);
FileHandler::writeFile($cache_file, $text);
$content = array();
$content[] = '<?php';
$content[] = 'if(!defined(\'__XE__\')) { exit(); }';
$content[] = 'return \'' . base64_encode(serialize($obj)) . '\';';
FileHandler::writeFile($cache_file, implode(PHP_EOL, $content));
}
/**
@ -111,14 +107,16 @@ class CacheFile extends CacheBase
*/
function get($key, $modified_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$content = FileHandler::readFile($cache_file);
$cache_file = FileHandler::exists($this->getCacheFileName($key));
if($cache_file) $content = include($cache_file);
if(!$content)
{
return false;
}
return unserialize($content);
return unserialize(base64_decode($content));
}
/**

View file

@ -8,7 +8,6 @@
*/
class CacheHandler extends Handler
{
/**
* instance of cache handler
* @var CacheBase
@ -129,6 +128,18 @@ class CacheHandler extends Handler
return false;
}
/**
* Get cache name by key
*
* @param string $key The key that will be associated with the item.
* @return string Returns cache name
*/
function getCacheKey($key)
{
$key = str_replace('/', ':', $key);
return __XE_VERSION__ . ':' . $key;
}
/**
* Get cached data
*
@ -139,6 +150,7 @@ class CacheHandler extends Handler
*/
function get($key, $modified_time = 0)
{
$key = $this->getCacheKey($key);
if(!$this->handler)
{
return false;
@ -158,6 +170,9 @@ class CacheHandler extends Handler
*/
function put($key, $obj, $valid_time = 0)
{
if(!$key) return false;
$key = $this->getCacheKey($key);
if(!$this->handler)
{
return false;
@ -173,6 +188,7 @@ class CacheHandler extends Handler
*/
function delete($key)
{
$key = $this->getCacheKey($key);
if(!$this->handler)
{
return false;
@ -190,6 +206,7 @@ class CacheHandler extends Handler
*/
function isValid($key, $modified_time)
{
$key = $this->getCacheKey($key);
if(!$this->handler)
{
return false;
@ -235,7 +252,7 @@ class CacheHandler extends Handler
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
}
return $this->keyGroupVersions[$keyGroupName] . ':' . $keyGroupName . ':' . $key;
return 'cache_group_' . $this->keyGroupVersions[$keyGroupName] . ':' . $keyGroupName . ':' . $key;
}
/**
@ -259,6 +276,11 @@ class CacheHandler extends Handler
*/
class CacheBase
{
/**
* Default valid time
* @var int
*/
var $valid_time = 36000;
/**
* Get cached data

View file

@ -8,13 +8,6 @@
*/
class CacheMemcache extends CacheBase
{
/**
* Default valid time
* @var int
*/
var $valid_time = 36000;
/**
* instance of Memcahe
* @var Memcahe

View file

@ -10,13 +10,6 @@
*/
class CacheWincache extends CacheBase
{
/**
* Default valid time
* @var int
*/
var $valid_time = 36000;
/**
* Get instance of CacheWincache
*

View file

@ -859,6 +859,19 @@ function delObjectVars($target_obj, $del_obj)
return $return_obj;
}
function getDestroyXeVars(&$vars)
{
$del_vars = array('error_return_url', 'success_return_url', 'ruleset', 'xe_validator_id');
foreach($del_vars as $var)
{
if(is_array($vars)) unset($vars[$var]);
else if(is_object($vars)) unset($vars->$var);
}
return $vars;
}
/**
* Change error_handing to debugPrint on php5 higher
*

View file

@ -376,37 +376,22 @@ class commentModel extends comment
$args->list_count = $obj->list_count;
// cache controll
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
if(strpos($args->module_srl, ",") === false)
{
$object_key = 'object_newest_comment_list:' . $obj->module_srl;
$cache_key = $oCacheHandler->getGroupKey('newestCommentsList', $object_key);
$output = $oCacheHandler->get($cache_key);
}
if(!$output)
{
if(strpos($args->module_srl, ",") === false)
if($args->module_srl)
{
if($args->module_srl)
// check if module is using comment validation system
$oCommentController = getController("comment");
$is_using_validation = $oCommentController->isModuleUsingPublishValidation($obj->module_srl);
if($is_using_validation)
{
// check if module is using comment validation system
$oCommentController = getController("comment");
$is_using_validation = $oCommentController->isModuleUsingPublishValidation($obj->module_srl);
if($is_using_validation)
{
$args->status = 1;
}
$args->status = 1;
}
}
$output = executeQuery('comment.getNewestCommentList', $args, $columnList);
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $output);
}
}
$output = executeQuery('comment.getNewestCommentList', $args, $columnList);
if(!$output->toBool())
{
return $output;

View file

@ -35,7 +35,7 @@ class counterModel extends counter
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$object_key = 'object:' . $site_srl . '_' . str_replace('.', '-', $args->ipaddress);
$object_key = 'counter:' . $site_srl . '_' . str_replace(array('.', ':'), '-', $args->ipaddress);
$cache_key = $oCacheHandler->getGroupKey('counterIpLogged_' . $args->regdate, $object_key);
if($oCacheHandler->isValid($cache_key))
{
@ -68,7 +68,7 @@ class counterModel extends counter
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:insertedTodayStatus:' . $site_srl . '_' . $args->regdate;
$cache_key = 'counter:insertedTodayStatus:' . $site_srl . '_' . $args->regdate;
if($oCacheHandler->isValid($cache_key))
{
return $oCacheHandler->get($cache_key);
@ -90,7 +90,7 @@ class counterModel extends counter
{
$oCacheHandler->put($cache_key, TRUE);
$_old_date = date('Ymd', strtotime('-1 day'));
$oCacheHandler->delete('object:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
$oCacheHandler->delete('counter:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
}
return $result;

View file

@ -190,17 +190,14 @@ class documentAdminController extends document
$oDB->commit();
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
foreach($document_srl_list as $document_srl)
{
$cache_key = 'object:'.$document_srl;
$oCacheHandler->delete($cache_key);
$cache_key_item = 'object_document_item:'.$document_srl;
$cache_key_item = 'document_item:'.$document_srl;
$oCacheHandler->delete($cache_key_item);
}
$oCacheHandler->invalidateGroupKey('documentList');
}
return new Object();
}
@ -447,21 +444,18 @@ class documentAdminController extends document
}
}
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
if(is_array($document_srl_list))
{
foreach($document_srl_list as $document_srl)
{
$cache_key = 'object:'.$document_srl;
$oCacheHandler->delete($cache_key);
$cache_key_item = 'object_document_item:'.$document_srl;
$cache_key_item = 'document_item:'.$document_srl;
$oCacheHandler->delete($cache_key_item);
$oCacheHandler->invalidateGroupKey('commentList_' . $document_srl);
}
}
$oCacheHandler->invalidateGroupKey('documentList');
}
return $output;
}

View file

@ -280,8 +280,6 @@ class document extends ModuleObject
if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment'))
{
$oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW');
$columnList = array('module_srl');
$moduleSrlList = $oModuleModel->getModuleSrlList(null, $columnList);
$args->commentStatus = 'DENY';

View file

@ -320,14 +320,6 @@ class documentController extends document
$this->addGrant($obj->document_srl);
$output->add('document_srl',$obj->document_srl);
$output->add('category_srl',$obj->category_srl);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$obj->document_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('documentList');
}
return $output;
}
@ -536,14 +528,11 @@ class documentController extends document
$output->add('document_srl',$obj->document_srl);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$obj->document_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('documentList');
//remove document item from cache
$cache_key = 'object_document_item:'.$obj->document_srl;
$cache_key = 'document_item:'.$obj->document_srl;
$oCacheHandler->delete($cache_key);
}
@ -631,13 +620,10 @@ class documentController extends document
$oDB->commit();
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$document_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('documentList');
$cache_key = 'object_document_item:'.$document_srl;
$cache_key = 'document_item:'.$document_srl;
$oCacheHandler->delete($cache_key);
}
@ -781,10 +767,9 @@ class documentController extends document
$oDB->commit();
// Clear cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('documentList');
}
return $output;
@ -803,6 +788,7 @@ class documentController extends document
// Call a trigger when the read count is updated (after)
$output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);
if(!$output->toBool()) return $output;
// Pass if read count is increaded on the session information
if($_SESSION['readed_document'][$document_srl]) return false;
@ -822,19 +808,9 @@ class documentController extends document
$args = new stdClass;
$args->document_srl = $document_srl;
$output = executeQuery('document.updateReadedCount', $args);
// Register session
$_SESSION['readed_document'][$document_srl] = true;
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$document_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('documentList');
//remove document item from cache
$cache_key = 'object_document_item:'.$document_srl;
$oCacheHandler->delete($cache_key);
}
return TRUE;
}
@ -928,6 +904,12 @@ class documentController extends document
$oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return new Object();
}
@ -1219,18 +1201,6 @@ class documentController extends document
$args->last_updater = $last_updater;
}
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$document_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('documentList');
//remove document item from cache
$cache_key = 'object_document_item:'.$document_srl;
$oCacheHandler->delete($cache_key);
}
return executeQuery('document.updateCommentCount', $args);
}

View file

@ -77,25 +77,49 @@ class documentItem extends Object
if(!$this->document_srl) return;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport() && !count($this->columnList))
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object_document_item:'.$this->document_srl;
$output = $oCacheHandler->get($cache_key);
$cache_key = 'document_item:' . $this->document_srl;
$document_item = $oCacheHandler->get($cache_key);
if($document_item)
{
$document_item = (object)$document_item->getVariables();
$this->columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
}
else
{
$this->columnList = array();
}
}
if(!$output)
$args = new stdClass();
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $this->columnList);
if(!$document_item)
{
$args = new stdClass();
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $this->columnList);
//insert in cache
if($output->data->document_srl && $oCacheHandler->isSupport())
$oCacheHandler->put($cache_key,$output);
$document_item = $output->data;
}
else
{
$document_item->readed_count = $output->data->readed_count;
$document_item->voted_count = $output->data->voted_count;
$document_item->blamed_count = $output->data->blamed_count;
$document_item->comment_count = $output->data->comment_count;
$document_item->trackback_count = $output->data->trackback_count;
}
$this->setAttribute($document_item, $load_extra_vars);
//insert in cache
if($this->document_srl && $oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $this);
}
$this->setAttribute($output->data,$load_extra_vars);
}
function setAttribute($attribute,$load_extra_vars=true)
function setAttribute($attribute, $load_extra_vars=true)
{
if(!$attribute->document_srl)
{
@ -105,15 +129,12 @@ class documentItem extends Object
$this->document_srl = $attribute->document_srl;
$this->lang_code = $attribute->lang_code;
$this->adds($attribute);
// Tags
if($this->get('tags'))
{
$tags = explode(',',$this->get('tags'));
$tag_count = count($tags);
for($i=0;$i<$tag_count;$i++)
{
if(trim($tags[$i])) $tag_list[] = trim($tags[$i]);
}
$tag_list = explode(',', $this->get('tags'));
$tag_list = array_map('trim', $tag_list);
$this->add('tag_list', $tag_list);
}

View file

@ -221,20 +221,6 @@ class documentModel extends document
$obj->sort_index = $sort_check->sort_index;
$obj->isExtraVars = $sort_check->isExtraVars;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$object_key = 'object:'.$obj->module_srl.'_category_srl:'.$obj->category_srl.'_list_count:'.$obj->list_count.'_search_target:'.$obj->search_target.'_search_keyword:'.$obj->search_keyword.'_page'.$obj->page.'_sort_index:'.$obj->sort_index.'_order_type:'.$obj->order_type;
$cache_key = $oCacheHandler->getGroupKey('documentList', $object_key);
$output = $oCacheHandler->get($cache_key);
if($output)
{
return $output;
}
}
$this->_setSearchOption($obj, $args, $query_id, $use_division);
if ($sort_check->isExtraVars)
@ -313,7 +299,7 @@ class documentModel extends document
}
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
$virtual_number --;
$virtual_number--;
}
if($load_extra_vars) $this->setToAllDocumentExtraVars();
@ -325,8 +311,6 @@ class documentModel extends document
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
}
}
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
return $output;
}
@ -379,60 +363,78 @@ class documentModel extends document
{
if(is_null($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
{
$oExtraVar = &ExtraVar::getInstance($module_srl);
$obj = new stdClass();
$obj->module_srl = $module_srl;
$obj->sort_index = 'var_idx';
$obj->order = 'asc';
$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
// correcting index order
$isFixed = FALSE;
if(is_array($output->data))
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$prevIdx = 0;
foreach($output->data as $no => $value)
$object_key = 'module_extra_keys:' . $module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$keys = $oCacheHandler->get($cache_key);
}
$oExtraVar = &ExtraVar::getInstance($module_srl);
if(!$keys)
{
$obj = new stdClass();
$obj->module_srl = $module_srl;
$obj->sort_index = 'var_idx';
$obj->order = 'asc';
$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
// correcting index order
$isFixed = FALSE;
if(is_array($output->data))
{
// case first
if($prevIdx == 0 && $value->idx != 1)
$prevIdx = 0;
foreach($output->data as $no => $value)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$args->var_idx = $value->idx;
$args->new_idx = 1;
executeQuery('document.updateDocumentExtraKeyIdx', $args);
executeQuery('document.updateDocumentExtraVarIdx', $args);
$prevIdx = 1;
$isFixed = TRUE;
continue;
}
// case first
if($prevIdx == 0 && $value->idx != 1)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$args->var_idx = $value->idx;
$args->new_idx = 1;
executeQuery('document.updateDocumentExtraKeyIdx', $args);
executeQuery('document.updateDocumentExtraVarIdx', $args);
$prevIdx = 1;
$isFixed = TRUE;
continue;
}
// case others
if($prevIdx > 0 && $prevIdx + 1 != $value->idx)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$args->var_idx = $value->idx;
$args->new_idx = $prevIdx + 1;
executeQuery('document.updateDocumentExtraKeyIdx', $args);
executeQuery('document.updateDocumentExtraVarIdx', $args);
$prevIdx += 1;
$isFixed = TRUE;
continue;
}
// case others
if($prevIdx > 0 && $prevIdx + 1 != $value->idx)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$args->var_idx = $value->idx;
$args->new_idx = $prevIdx + 1;
executeQuery('document.updateDocumentExtraKeyIdx', $args);
executeQuery('document.updateDocumentExtraVarIdx', $args);
$prevIdx += 1;
$isFixed = TRUE;
continue;
}
$prevIdx = $value->idx;
$prevIdx = $value->idx;
}
}
if($isFixed)
{
$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
}
$oExtraVar->setExtraVarKeys($output->data);
$keys = $oExtraVar->getExtraVars();
if(!$keys) $keys = array();
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $keys);
}
}
if($isFixed)
{
$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
}
$oExtraVar->setExtraVarKeys($output->data);
$keys = $oExtraVar->getExtraVars();
if(!$keys) $keys = array();
$GLOBALS['XE_EXTRA_KEYS'][$module_srl] = $keys;
}

View file

@ -176,6 +176,12 @@ class layoutAdminController extends layout
{
$output = executeQuery('layout.updateModuleLayout', $update_args);
}
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
}
}
}
@ -257,10 +263,11 @@ class layoutAdminController extends layout
$cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
FileHandler::removeFile($cache_file);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$args->layout_srl;
$object_key = 'layout:' . $args->layout_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
}
@ -330,10 +337,11 @@ class layoutAdminController extends layout
$args->layout_srl = $layout_srl;
$output = executeQuery("layout.deleteLayout", $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$layout_srl;
$object_key = 'layout:'.$layout_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
if(!$output->toBool()) return $output;

View file

@ -86,6 +86,8 @@ class layout extends ModuleObject
$oDB->addColumn('layouts','layout_type','char',1,'P',true);
}
$oCacheHandler = CacheHandler::getInstance('object', null, true);
$args->layout = '.';
$output = executeQueryArray('layout.getLayoutDotList', $args);
if($output->data && count($output->data) > 0)
@ -99,6 +101,13 @@ class layout extends ModuleObject
$args->layout = implode('|@|', $layout_path);
$args->layout_srl = $layout->layout_srl;
$output = executeQuery('layout.updateLayout', $args);
if($oCacheHandler->isSupport())
{
$object_key = 'layout:' . $args->layout_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
}
}
}

View file

@ -259,12 +259,14 @@ class layoutModel extends layout
function getLayout($layout_srl)
{
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$layout_srl;
$object_key = 'layout:' . $layout_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$layout_info = $oCacheHandler->get($cache_key);
}
if(!$layout_info)
{
// Get information from the DB
@ -272,18 +274,12 @@ class layoutModel extends layout
$args->layout_srl = $layout_srl;
$output = executeQuery('layout.getLayout', $args);
if(!$output->data) return;
// Return xml file informaton after listing up the layout and extra_vars
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
// If deleted layout files, delete layout instance
// if (!$layout_info) {
// $oLayoutController = getAdminController('layout');
// $oLayoutController->deleteLayout($layout_srl);
// return;
// }
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$layout_info);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $layout_info);
}
return $layout_info;
}
@ -294,7 +290,9 @@ class layoutModel extends layout
$args->layout_srl = $layout_srl;
$output = executeQuery('layout.getLayout', $args, $columnList);
if(!$output->toBool())
{
return;
}
return $output->data;
}

View file

@ -1063,7 +1063,10 @@ class memberAdminController extends member
$args->source_group_srl = $source_group_srl;
$args->target_group_srl = $target_group_srl;
return executeQuery('member.changeGroup', $args);
$output = executeQuery('member.changeGroup', $args);
$this->_deleteMemberGroupCache($site_srl);
return $output;
}
/**
@ -1075,7 +1078,7 @@ class memberAdminController extends member
{
if(!$args->site_srl) $args->site_srl = 0;
// Check the value of is_default.
if($args->is_default!='Y')
if($args->is_default != 'Y')
{
$args->is_default = 'N';
}
@ -1088,6 +1091,7 @@ class memberAdminController extends member
if(!$args->group_srl) $args->group_srl = getNextSequence();
$output = executeQuery('member.insertGroup', $args);
$this->_deleteMemberGroupCache($args->site_srl);
return $output;
}
@ -1126,20 +1130,22 @@ class memberAdminController extends member
{
// Create a member model object
$oMemberModel = getModel('member');
// Check the group_srl (If is_default == 'Y', it cannot be deleted)
$columnList = array('group_srl', 'is_default');
$group_info = $oMemberModel->getGroup($group_srl, $columnList);
if(!$group_info) return new Object(-1, 'lang->msg_not_founded');
if($group_info->is_default == 'Y') return new Object(-1, 'msg_not_delete_default');
// Get groups where is_default == 'Y'
$columnList = array('site_srl', 'group_srl');
$default_group = $oMemberModel->getDefaultGroup($site_srl, $columnList);
$default_group_srl = $default_group->group_srl;
// Change to default_group_srl
$this->changeGroup($group_srl, $default_group_srl);
$args = new stdClass;
$args->group_srl = $group_srl;
$output = executeQuery('member.deleteGroup', $args);
@ -1233,11 +1239,10 @@ class memberAdminController extends member
function _deleteMemberGroupCache($site_srl = 0)
{
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object', null, true);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_groups:'.$site_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('member');
}
}

View file

@ -1446,7 +1446,6 @@ class memberController extends member
$args->member_srl = $member_srl;
$args->group_srl = $group_srl;
if($site_srl) $args->site_srl = $site_srl;
$oModel =& getModel('member');
$groups = $oModel->getMemberGroups($member_srl, $site_srl, true);
if($groups[$group_srl]) return new Object();
@ -1455,10 +1454,15 @@ class memberController extends member
$output = executeQuery('member.addMemberToGroup',$args);
$output2 = ModuleHandler::triggerCall('member.addMemberToGroup', 'after', $args);
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_member_groups:'.$member_srl.'_'.$site_srl;
$object_key = 'member_groups:' . getNumberingPath($args->member_srl) . $args->member_srl . '_'.$args->site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
$object_key = 'member_info:' . getNumberingPath($args->member_srl) . $args->member_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
}
@ -1499,14 +1503,20 @@ class memberController extends member
$obj->regdate = $date[$obj->member_srl];
$output = executeQuery('member.addMemberToGroup', $obj);
if(!$output->toBool()) return $output;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'member_groups:' . getNumberingPath($args->member_srl) . $args->member_srl . '_' . $args->site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
$object_key = 'member_info:' . getNumberingPath($args->member_srl) . $args->member_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
}
}
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object_member_groups:'.$member_srl.'_'.$site_srl;
$oCacheHandler->delete($cache_key);
}
return new Object();
}
@ -2117,15 +2127,17 @@ class memberController extends member
}
$oDB->commit();
// Save Session
if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$args->member_srl;
$cache_key = 'member:info:'.$args->member_srl;
$oCacheHandler->delete($cache_key);
}
// Save Session
if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
$logged_info = Context::get('logged_info');
$output->add('member_srl', $args->member_srl);
@ -2139,10 +2151,10 @@ class memberController extends member
{
$output = executeQuery('member.updateChangePasswordDate', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$args->member_srl;
$cache_key = 'member:info:'.$args->member_srl;
$oCacheHandler->delete($cache_key);
}

View file

@ -221,7 +221,7 @@ class memberModel extends member
else
{
// Register a default group if the site doesn't have a member group
if(!count($logged_info->group_list))
if(count($logged_info->group_list) === 0)
{
$default_group = $this->getDefaultGroup(0);
$oMemberController = getController('member');
@ -284,10 +284,11 @@ class memberModel extends member
//columnList size zero... get full member info
if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0)
{
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$member_srl;
$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$GLOBALS['__member_info__'][$member_srl] = $oCacheHandler->get($cache_key);
}
@ -296,7 +297,11 @@ class memberModel extends member
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList);
if(!$output->data) return;
if(!$output->data)
{
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass);
return;
}
$this->arrangeMemberInfo($output->data, $site_srl);
//insert in cache
@ -442,28 +447,29 @@ class memberModel extends member
function getMemberGroups($member_srl, $site_srl = 0, $force_reload = false)
{
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_member_groups:'.$member_srl.'_'.$site_srl;
$output = $oCacheHandler->get($cache_key);
$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_'.$site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$group_list = $oCacheHandler->get($cache_key);
}
static $member_groups = array();
if(!$member_groups[$member_srl][$site_srl] || $force_reload)
{
if(!$output)
if(!$group_list && !is_array($group_list))
{
$args = new stdClass();
$args->member_srl = $member_srl;
$args->site_srl = $site_srl;
$output = executeQuery('member.getMemberGroups', $args);
$output = executeQueryArray('member.getMemberGroups', $args);
$group_list = $output->data;
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list);
}
if(!$output->data) return array();
$group_list = $output->data;
if(!is_array($group_list)) $group_list = array($group_list);
if(!$group_list) return array();
foreach($group_list as $group)
{
@ -498,10 +504,27 @@ class memberModel extends member
*/
function getDefaultGroup($site_srl = 0, $columnList = array())
{
$args = new stdClass();
$args->site_srl = $site_srl;
$output = executeQuery('member.getDefaultGroup', $args, $columnList);
return $output->data;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'default_group_' . $site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$default_group = $oCacheHandler->get($cache_key);
}
if(!$default_group)
{
$args = new stdClass();
$args->site_srl = $site_srl;
$output = executeQuery('member.getDefaultGroup', $args, $columnList);
$default_group = $output->data;
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $default_group);
}
}
return $default_group;
}
/**
@ -538,13 +561,14 @@ class memberModel extends member
$site_srl = 0;
}
$oCacheHandler = &CacheHandler::getInstance('object', null, true);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_groups:'.$site_srl;
$output = $oCacheHandler->get($cache_key);
$object_key = 'member_groups:site_'.$site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$group_list = $oCacheHandler->get($cache_key);
}
if(!$output)
if(!$group_list)
{
$args = new stdClass();
@ -552,16 +576,16 @@ class memberModel extends member
$args->sort_index = 'list_order';
$args->order_type = 'asc';
$output = executeQueryArray('member.getGroups', $args);
$group_list = $output->data;
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list);
}
if(!$output->toBool() || !$output->data)
if(!$group_list)
{
return array();
}
$group_list = $output->data;
foreach($group_list as $val)
{

View file

@ -305,6 +305,12 @@ class module extends ModuleObject
$module_info->skin_vars = null;
$module_info->admin_id = null;
executeQuery('module.updateModule', $module_info);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
}
}
// Various column drop
@ -554,6 +560,11 @@ class module extends ModuleObject
$output = executeQuery('module.updateModule', $moduleInfo);
if(!$output->toBool())
{
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
}

View file

@ -27,6 +27,14 @@ class moduleController extends module
$args->act = $act;
$output = executeQuery('module.insertActionForward', $args);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'action_forward';
$oCacheHandler->delete($cache_key);
}
return $output;
}
@ -41,6 +49,14 @@ class moduleController extends module
$args->act = $act;
$output = executeQuery('module.deleteActionForward', $args);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'action_forward';
$oCacheHandler->delete($cache_key);
}
return $output;
}
@ -61,12 +77,10 @@ class moduleController extends module
$output = executeQuery('module.insertTrigger', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object', NULL, TRUE);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('triggers');
$cache_key = 'object:'.$trigger_name.'_'.$called_position;
$oCacheHandler->delete($cache_key);
}
// Delete all the files which contain trigger information
@ -91,12 +105,10 @@ class moduleController extends module
$output = executeQuery('module.deleteTrigger', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object', NULL, TRUE);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('triggers');
$cache_key = 'object:'.$trigger_name.'_'.$called_position;
$oCacheHandler->delete($cache_key);
}
// Remove the trigger cache
@ -187,11 +199,10 @@ class moduleController extends module
$output = executeQuery('module.insertModuleConfig', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object', NULL, TRUE);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:module_config:module_'.$module.'_site_srl_'.$site_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -210,15 +221,15 @@ class moduleController extends module
$output = executeQuery('module.deleteModulePartConfig', $args);
if(!$output->toBool()) return $output;
$output = executeQuery('module.insertModulePartConfig', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object', NULL, TRUE);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_part_config:'.$module.'_'.$module_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('site_and_module');
}
$output = executeQuery('module.insertModulePartConfig', $args);
return $output;
}
@ -288,17 +299,12 @@ class moduleController extends module
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->index_module_srl);
$mid = $module_info->mid;
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
if($args->site_srl == 0)
{
$cache_key = 'object_default_mid:_';
$oCacheHandler->delete($cache_key);
}
$cache_key = 'object_default_mid:'.$vid.'_'.$mid;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -473,6 +479,12 @@ class moduleController extends module
// commit
$oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
$output->add('module_srl',$args->module_srl);
return $output;
}
@ -554,7 +566,7 @@ class moduleController extends module
foreach($menuOutput->data as $itemInfo)
{
$itemInfo->url = $args->mid;
$updateMenuItemOutput = $oMenuAdminController->updateMenuItem($itemInfo);
if(!$updateMenuItemOutput->toBool())
{
@ -563,7 +575,7 @@ class moduleController extends module
}
}
}
// if mid changed, change mid of success_return_url to new mid
if($module_info->mid != $args->mid && Context::get('success_return_url'))
{
@ -578,16 +590,12 @@ class moduleController extends module
$output->add('module_srl',$args->module_srl);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_info:'.$args->module_srl;
$oCacheHandler->delete($cache_key);
$cache_key = 'object:'.$args->mid.'_'.$args->site_srl;
$oCacheHandler->delete($cache_key);
$cache_key = 'object:module_extra_vars_'.$args->module_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -600,7 +608,17 @@ class moduleController extends module
$args->module_srl = $module_srl;
$args->site_srl = $site_srl;
$args->layout_srl = $layout_srl;
return executeQuery('module.updateModuleSite', $args);
$output = executeQuery('module.updateModuleSite', $args);
if(!$output->toBool()) return $output;
//remove from cache
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
/**
@ -721,14 +739,12 @@ class moduleController extends module
// commit
$oDB->commit();
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_info:'.$args->module_srl;
$oCacheHandler->delete($cache_key);
$cache_key = 'object:module_extra_vars_'.$args->module_srl;
$oCacheHandler->delete($cache_key);
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -750,6 +766,12 @@ class moduleController extends module
$output = executeQuery('module.clearDefaultModule');
if(!$output->toBool()) return $output;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -758,7 +780,15 @@ class moduleController extends module
*/
function updateModuleMenu($args)
{
return executeQuery('module.updateModuleMenu', $args);
$output = executeQuery('module.updateModuleMenu', $args);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
/**
@ -772,6 +802,13 @@ class moduleController extends module
$args->layout_srl = $layout_srl;
$args->menu_srls = implode(',',$menu_srl_list);
$output = executeQuery('module.updateModuleLayout', $args);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
@ -896,6 +933,7 @@ class moduleController extends module
return $output;
}
getDestroyXeVars($obj);
if(!$obj || !count($obj)) return new Object();
$args = new stdClass;
@ -929,6 +967,7 @@ class moduleController extends module
}
$oDB->commit;
return new Object();
}
@ -961,17 +1000,18 @@ class moduleController extends module
if($mode === 'P')
{
$cache_key = 'object_module_skin_vars:'.$module_srl;
$object_key = 'module_skin_vars:'.$module_srl;
$query = 'module.deleteModuleSkinVars';
}
else
{
$cache_key = 'object_module_mobile_skin_vars:'.$module_srl;
$object_key = 'module_mobile_skin_vars:'.$module_srl;
$query = 'module.deleteModuleMobileSkinVars';
}
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
if($oCacheHandler->isSupport())
{
$oCacheHandler->delete($cache_key);
@ -986,6 +1026,7 @@ class moduleController extends module
function insertModuleExtraVars($module_srl, $obj)
{
$this->deleteModuleExtraVars($module_srl);
getDestroyXeVars($obj);
if(!$obj || !count($obj)) return;
foreach($obj as $key => $val)
@ -997,6 +1038,14 @@ class moduleController extends module
if(!$args->name || !$args->value) continue;
$output = executeQuery('module.insertModuleExtraVars', $args);
}
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'module_extra_vars:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
}
/**
@ -1006,14 +1055,18 @@ class moduleController extends module
{
$args = new stdClass();
$args->module_srl = $module_srl;
return executeQuery('module.deleteModuleExtraVars', $args);
$output = executeQuery('module.deleteModuleExtraVars', $args);
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:module_extra_vars_'.$module_srl;
$object_key = 'module_extra_vars:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
return $output;
}
/**
@ -1191,7 +1244,7 @@ class moduleController extends module
// Check uploaded file
if(!checkUploadedFile($tmp)) return false;
if(!@move_uploaded_file($tmp, $save_filename))
{
return false;
@ -1228,7 +1281,7 @@ class moduleController extends module
// Check uploaded file
if(!checkUploadedFile($tmp)) return false;
// upload
if(!@move_uploaded_file($tmp, $save_filename))
{
@ -1317,6 +1370,13 @@ class moduleController extends module
$args = new stdClass;
$args->site_srls = $site_srls;
$output = executeQuery('module.updateModuleInSites', $args);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
return $output;
}
}

View file

@ -113,30 +113,44 @@ class moduleModel extends module
}
}
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
// If domain is set, look for subsite
if($domain !== '')
{
if($oCacheHandler->isSupport()) $output = $oCacheHandler->get('domain_' . $domain);
if(!$output)
if($oCacheHandler->isSupport())
{
$object_key = 'site_info:' . $domain;
$domain_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$site_info = $oCacheHandler->get($domain_cache_key);
}
if(!isset($site_info))
{
$args = new stdClass();
$args->domain = $domain;
$output = executeQuery('module.getSiteInfoByDomain', $args);
if($oCacheHandler->isSupport() && $output->data) $oCacheHandler->put('domain_' . $domain, $output);
$site_info = $output->data;
if($oCacheHandler->isSupport()) $oCacheHandler->put($domain_cache_key, $site_info);
}
if($output->toBool() && $output->data && $vid)
if($site_info && $vid)
{
Context::set('vid', $output->data->domain, true);
if(strtolower($mid)==strtolower($output->data->domain)) Context::set('mid',$output->data->mid,true);
Context::set('vid', $site_info->domain, true);
if(strtolower($mid)==strtolower($site_info->domain)) Context::set('mid', $site_info->mid,true);
}
if(!$output || !$output->data) { $domain = ''; unset($output); }
if(!$site_info || !$site_info->domain) { $domain = ''; unset($site_info); }
}
// If no virtual website was found, get default website
if($domain === '')
{
if($oCacheHandler->isSupport()) $output = $oCacheHandler->get('default_site');
if(!$output)
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);
}
if(!$module_info)
{
$args = new stdClass();
$args->site_srl = 0;
@ -148,6 +162,7 @@ class moduleModel extends module
$oDB = &DB::getInstance();
if(!$oDB->isTableExists('sites')) $oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml');
if(!$oDB->isTableExists('sites')) return;
// Get mid, language
$mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args);
$db_info = Context::getDBInfo();
@ -172,10 +187,11 @@ class moduleModel extends module
}
$output = executeQuery('module.getSiteInfo', $args);
}
if($oCacheHandler->isSupport()) $oCacheHandler->put('default_site',$output);
$module_info = $output->data;
if($oCacheHandler->isSupport()) $oCacheHandler->put($default_site_cache_key, $module_info);
}
}
$module_info = $output->data;
if(!$module_info->module_srl) return $module_info;
if(is_array($module_info) && $module_info->data[0]) $module_info = $module_info[0];
return $this->addModuleExtraVars($module_info);
@ -194,30 +210,34 @@ class moduleModel extends module
$args = new stdClass();
$args->mid = $mid;
$args->site_srl = (int)$site_srl;
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$mid.'_'.$site_srl;
$module_srl = $oCacheHandler->get($cache_key);
$object_key = 'module_srl:'.$mid.'_'.$site_srl;
$module_srl_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$module_srl = $oCacheHandler->get($module_srl_cache_key);
if($module_srl)
{
$cache_key = 'object_module_info:'.$module_srl;
$output = $oCacheHandler->get($cache_key);
}
}
if(!$output)
{
$output = executeQuery('module.getMidInfo', $args);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$mid.'_'.$site_srl;
$oCacheHandler->put($cache_key,$output->data->module_srl);
$cache_key = 'object_module_info:'.$output->data->module_srl;
$oCacheHandler->put($cache_key,$output);
$object_key = 'module_info:' . $module_srl;
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$module_info = $oCacheHandler->get($module_info_cache_key);
}
}
if(!$module_info && !is_array($module_info))
{
$output = executeQuery('module.getMidInfo', $args);
$module_info = $output->data;
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($module_srl_cache_key, $module_info->module_srl);
$object_key = 'module_info:' . $module_info->module_srl;
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->put($module_info_cache_key, $module_info);
}
}
$module_info = $output->data;
$this->applyDefaultSkin($module_info);
if(!$module_info->module_srl && $module_info->data[0]) $module_info = $module_info->data[0];
return $this->addModuleExtraVars($module_info);
@ -288,23 +308,26 @@ class moduleModel extends module
$moduleInfo->designSettings->skin->mobileIsDefault = $moduleInfo->is_mskin_fix == 'N' ? 1 : 0;
$moduleInfo->designSettings->skin->mobile = $skinInfoMobile->title;
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$mid.'_'.$site_srl;
$module_srl = $oCacheHandler->get($cache_key);
$object_key = 'module_srl:'.$mid.'_'.$site_srl;
$module_srl_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$module_srl = $oCacheHandler->get($module_srl_cache_key);
if($module_srl)
{
$cache_key = 'object_module_info:'.$module_srl;
$coutput = $oCacheHandler->get($cache_key);
$object_key = 'module_info:' . $module_srl;
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$coutput = $oCacheHandler->get($module_info_cache_key);
}
if(!$coutput)
{
$cache_key = 'object:'.$mid.'_'.$site_srl;
$oCacheHandler->put($cache_key, $output->data->module_srl);
$cache_key = 'object_module_info:'.$output->data->module_srl;
$oCacheHandler->put($cache_key, $moduleInfo);
$oCacheHandler->put($module_srl_cache_key, $output->data->module_srl);
$object_key = 'module_info:' . $output->data->module_srl;
$module_info_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->put($module_info_cache_key, $moduleInfo);
}
else
{
@ -333,23 +356,28 @@ class moduleModel extends module
// Get data
$args = new stdClass();
$args->module_srl = $module_srl;
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_info:'.$module_srl;
$output = $oCacheHandler->get($cache_key);
$object_key = 'module_info:' . $module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$mid_info = $oCacheHandler->get($cache_key);
}
if(!$output)
if(!$mid_info && !is_array($mid_info))
{
$output = executeQuery('module.getMidInfo', $args );
if(!$output->data) return;
$this->applyDefaultSkin($output->data);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
$output = executeQuery('module.getMidInfo', $args);
if(!$output->toBool()) return;
$mid_info = $output->data;
$this->applyDefaultSkin($mid_info);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $mid_info);
}
if(count($columnList))
if($mid_info && count($columnList))
{
$module_info = new stdClass();
foreach($output->data as $key => $item)
foreach($mid_info as $key => $item)
{
if(in_array($key, $columnList))
{
@ -357,7 +385,8 @@ class moduleModel extends module
}
}
}
else $module_info = $output->data;
else $module_info = $mid_info;
return $this->addModuleExtraVars($module_info);
}
@ -450,10 +479,33 @@ class moduleModel extends module
*/
function getMidList($args = null, $columnList = array())
{
$output = executeQuery('module.getMidList', $args, $columnList);
if(!$output->toBool()) return $output;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
if(count($args) === 1 && isset($args->site_srl))
{
$object_key = 'module:mid_list_' . $args->site_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$list = $oCacheHandler->get($cache_key);
}
}
$list = $output->data;
if(!$list)
{
if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl))
{
$columnList = array();
}
$output = executeQuery('module.getMidList', $args, $columnList);
if(!$output->toBool()) return $output;
$list = $output->data;
if($oCacheHandler->isSupport() && count($args) === 1 && isset($args->site_srl))
{
$oCacheHandler->put($cache_key, $list);
}
}
if(!$list) return;
if(!is_array($list)) $list = array($list);
@ -510,14 +562,38 @@ class moduleModel extends module
/**
* @brief Get forward value by the value of act
*/
function getActionForward($act, $module = "")
function getActionForward($act, $module = '')
{
$args = new stdClass();
$args->act = $act;
$args->module = ($module)?$module:null;
if(strlen ($args->module) > 0) $output = executeQuery ('module.getActionForwardWithModule', $args);
else $output = executeQuery('module.getActionForward',$args);
return $output->data;
// cache controll
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'action_forward';
$action_forward = $oCacheHandler->get($cache_key);
}
if(!$action_forward)
{
$args = new stdClass();
$args->act = $act;
$args->module = ($module) ? $module : null;
if(strlen($args->module) > 0)
{
$output = executeQuery('module.getActionForwardWithModule', $args);
}
else
{
$output = executeQuery('module.getActionForward',$args);
}
$action_forward = $output->data;
debugPrint($action_forward);
if($oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $action_forward);
}
}
return $action_forward;
}
/**
@ -526,28 +602,29 @@ class moduleModel extends module
function getTriggers($trigger_name, $called_position)
{
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object', NULL, TRUE);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$object_key = 'object:'.$trigger_name.'_'.$called_position;
$object_key = $trigger_name.'_'.$called_position;
$cache_key = $oCacheHandler->getGroupKey('triggers', $object_key);
$output = $oCacheHandler->get($cache_key);
$triggers = $oCacheHandler->get($cache_key);
}
if(!$output)
if(!isset($triggers))
{
$args = new stdClass();
$args->trigger_name = $trigger_name;
$args->called_position = $called_position;
$output = executeQueryArray('module.getTriggers',$args);
$triggers = $output->data;
if($output->toBool() && $oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $output);
if($output->toBool() && $oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $triggers);
}
}
return $output->data;
return $triggers;
}
/**
@ -641,7 +718,7 @@ class moduleModel extends module
$xml_obj = $tmp_xml_obj->module;
if(!$xml_obj) return;
// Module Information
$module_info = new stdClass();
$author_obj = new stdClass();
@ -1247,10 +1324,11 @@ class moduleModel extends module
function getModuleConfig($module, $site_srl = 0)
{
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object', null, true);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:module_config:module_'.$module.'_site_srl_'.$site_srl;
$object_key = 'module_config:' . $module . '_' . $site_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$config = $oCacheHandler->get($cache_key);
}
if(!$config)
@ -1262,11 +1340,11 @@ class moduleModel extends 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())
{
if($config)
$oCacheHandler->put($cache_key,$config);
$oCacheHandler->put($cache_key, $config);
}
$GLOBALS['__ModuleConfig__'][$site_srl][$module] = $config;
}
@ -1283,10 +1361,11 @@ class moduleModel extends module
function getModulePartConfig($module, $module_srl)
{
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object', null, true);
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_part_config:'.$module.'_'.$module_srl;
$object_key = 'module_part_config:'.$module.'_'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$config = $oCacheHandler->get($cache_key);
}
if(!$config)
@ -1298,10 +1377,11 @@ class moduleModel extends 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())
{
if($config) $oCacheHandler->put($cache_key,$config);
$oCacheHandler->put($cache_key, $config);
}
$GLOBALS['__ModulePartConfig__'][$module][$module_srl] = $config;
}
@ -1591,43 +1671,71 @@ class moduleModel extends module
* @brief Get extra vars of the module
* Extra information, not in the modules table
*/
function getModuleExtraVars($module_srl)
function getModuleExtraVars($list_module_srl)
{
if(is_array($module_srl)) $module_srl = implode(',',$module_srl);
$extra_vars = array();
$get_module_srls = array();
if(!is_array($list_module_srl)) $list_module_srl = array($list_module_srl);
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:module_extra_vars_'.$module_srl;
$vars = $oCacheHandler->get($cache_key);
foreach($list_module_srl as $module_srl)
{
$object_key = 'module_extra_vars:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$vars = $oCacheHandler->get($cache_key);
if($vars)
{
$extra_vars[$module_srl] = $vars;
}
else
{
$get_module_srls[] = $module_srl;
}
}
}
if(!$vars)
if(count($get_module_srls))
{
$args = new stdClass();
$args->module_srl = $module_srl;
$output = executeQueryArray('module.getModuleExtraVars',$args);
if(!$output->toBool() || !$output->data)
$args->module_srl = implode(',', $get_module_srls);
$output = executeQueryArray('module.getModuleExtraVars', $args);
if(!$output->toBool())
{
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,'empty_extra_vars');
return;
}
$vars = array();
if(!$output->data)
{
foreach($get_module_srls as $module_srl)
{
$extra_vars[$module_srl] = new stdClass;
}
}
foreach($output->data as $key => $val)
{
if(in_array($val->name, array('mid','module')) || $val->value == 'Array') continue;
if(!isset($vars[$val->module_srl]))
if(!isset($extra_vars[$val->module_srl]))
{
$vars[$val->module_srl] = new stdClass();
$extra_vars[$val->module_srl] = new stdClass();
}
$extra_vars[$val->module_srl]->{$val->name} = $val->value;
if($oCacheHandler->isSupport())
{
$object_key = 'module_extra_vars:'.$val->module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->put($cache_key, $extra_vars[$val->module_srl]);
}
$vars[$val->module_srl]->{$val->name} = $val->value;
}
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$vars);
}
else if($vars == 'empty_extra_vars')
{
return;
}
return $vars;
return $extra_vars;
}
/**
@ -1635,13 +1743,30 @@ class moduleModel extends module
*/
function getModuleSkinVars($module_srl)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$output = executeQueryArray('module.getModuleSkinVars',$args);
if(!$output->toBool() || !$output->data) return;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'module_skin_vars:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$skin_vars = $oCacheHandler->get($cache_key);
}
if(!$skin_vars)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$output = executeQueryArray('module.getModuleSkinVars',$args);
if(!$output->toBool()) return;
$skin_vars = array();
foreach($output->data as $vars)
{
$skin_vars[$vars->name] = $vars;
}
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
}
$skin_vars = array();
foreach($output->data as $val) $skin_vars[$val->name] = $val;
return $skin_vars;
}
@ -1706,37 +1831,22 @@ class moduleModel extends module
{
if(!$module_info->module_srl) return;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if(Mobile::isFromMobilePhone())
{
$cache_key = 'object_module_mobile_skin_vars:' . $module_info->module_srl;
$query = 'module.getModuleMobileSkinVars';
$skin_vars = $this->getModuleMobileSkinVars($module_info->module_srl);
}
else
{
$cache_key = 'object_module_skin_vars:' . $module_info->module_srl;
$query = 'module.getModuleSkinVars';
$skin_vars = $this->getModuleSkinVars($module_info->module_srl);
}
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$output = $oCacheHandler->get($cache_key);
}
if(!$output)
{
$args = new stdClass();
$args->module_srl = $module_info->module_srl;
$output = executeQueryArray($query,$args);
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
}
if(!$output->toBool() || !$output->data) return;
if(!$skin_vars) return;
foreach($output->data as $val)
foreach($skin_vars as $name => $val)
{
if(isset($module_info->{$val->name})) continue;
$module_info->{$val->name} = $val->value;
if(isset($module_info->{$name})) continue;
$module_info->{$name} = $val->value;
}
}
@ -1747,13 +1857,30 @@ class moduleModel extends module
*/
function getModuleMobileSkinVars($module_srl)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$output = executeQueryArray('module.getModuleMobileSkinVars',$args);
if(!$output->toBool() || !$output->data) return;
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'module_mobile_skin_vars:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$skin_vars = $oCacheHandler->get($cache_key);
}
if(!$skin_vars)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$output = executeQueryArray('module.getModuleMobileSkinVars',$args);
if(!$output->toBool() || !$output->data) return;
$skin_vars = array();
foreach($output->data as $vars)
{
$skin_vars[$vars->name] = $vars;
}
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
}
$skin_vars = array();
foreach($output->data as $val) $skin_vars[$val->name] = $val;
return $skin_vars;
}
@ -1765,21 +1892,25 @@ class moduleModel extends module
{
if(!$module_info->module_srl) return;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object_module_mobile_skin_vars:'.$module_info->module_srl;
$output = $oCacheHandler->get($cache_key);
$object_key = 'module_mobile_skin_vars:'.$module_info->module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$skin_vars = $oCacheHandler->get($cache_key);
}
if(!$output)
if(!$skin_vars)
{
$args = new stdClass;
$args->module_srl = $module_info->module_srl;
$output = executeQueryArray('module.getModuleMobileSkinVars',$args);
if(!$output->toBool()) return;
$skin_vars = $output->data;
//insert in cache
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $skin_vars);
}
if(!$output->toBool() || !$output->data) return;
if(!$skin_vars) return;
foreach($output->data as $val)
{

View file

@ -361,6 +361,12 @@ class pointAdminController extends point
executeQuery('module.deleteModulePartConfig', $args);
}
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('site_and_module');
}
$this->setMessage('success_updated');
}

View file

@ -641,15 +641,16 @@ class pointController extends point
$cache_filename = sprintf('%s%d.cache.txt', $cache_path, $member_srl);
FileHandler::writeFile($cache_filename, $point);
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$member_srl;
$GLOBALS['__member_info__'][$member_srl] = null;
$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_0';
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
$gcache_key = 'object_member_groups:'.$member_srl.'_0';
$oCacheHandler->delete($gcache_key);
$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
}
return $output;

View file

@ -27,10 +27,10 @@ class sessionController extends session
function write($session_key, $val)
{
if(!$session_key || !$this->session_started) return;
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$cache_vars = $oCacheHandler->get($cache_key);
}
@ -80,7 +80,7 @@ class sessionController extends session
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
//put session into db
@ -91,7 +91,7 @@ class sessionController extends session
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
}
@ -101,7 +101,7 @@ class sessionController extends session
//put session into cache
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$oCacheHandler->put($cache_key,$args,$this->lifetime);
}
//put session into db
@ -116,10 +116,10 @@ class sessionController extends session
{
if(!$session_key || !$this->session_started) return;
//remove session from cache
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$oCacheHandler->delete($cache_key);
}
//remove session from db

View file

@ -25,10 +25,10 @@ class sessionModel extends session
$output = new Object();
$oCacheHandler = &CacheHandler::getInstance('object');
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$cache_key = 'object:'.$session_key;
$cache_key = 'session:'.$session_key;
$output->data = $oCacheHandler->get($cache_key);
}