Fix missing extra vars when document cache is cleared in the middle of a script #2553

This commit is contained in:
Kijin Sung 2025-05-15 20:11:49 +09:00
parent 1d558204d1
commit a1f452fa83
2 changed files with 9 additions and 9 deletions

View file

@ -1775,6 +1775,7 @@ class DocumentController extends Document
$output = executeQuery('document.updateDocumentExtraVar', $obj); $output = executeQuery('document.updateDocumentExtraVar', $obj);
} }
unset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]);
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl"); Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
return $output; return $output;
} }
@ -1831,6 +1832,7 @@ class DocumentController extends Document
$oDB->commit(); $oDB->commit();
unset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]);
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl"); Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
return new BaseObject(); return new BaseObject();
} }
@ -3708,6 +3710,7 @@ Content;
if ($type === 'all' || $type === 'extra_vars') if ($type === 'all' || $type === 'extra_vars')
{ {
unset($GLOBALS['XE_EXTRA_VARS'][$document_srl]); unset($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
unset($GLOBALS['XE_EXTRA_CHK'][$document_srl]);
unset($GLOBALS['RX_DOCUMENT_LANG'][$document_srl]); unset($GLOBALS['RX_DOCUMENT_LANG'][$document_srl]);
} }
} }

View file

@ -55,19 +55,16 @@ class DocumentModel extends Document
return; return;
} }
static $checked = array();
static $module_extra_keys = array();
// check documents // check documents
$document_srls = array(); $document_srls = array();
foreach($_document_list as $document_srl => $oDocument) foreach($_document_list as $document_srl => $oDocument)
{ {
if(isset($checked[$document_srl]) || !($oDocument instanceof documentItem) || !$oDocument->isExists()) if(isset($GLOBALS['XE_EXTRA_CHK'][$document_srl]) || !($oDocument instanceof documentItem) || !$oDocument->isExists())
{ {
continue; continue;
} }
$checked[$document_srl] = true; $GLOBALS['XE_EXTRA_CHK'][$document_srl] = true;
$document_srls[] = $document_srl; $document_srls[] = $document_srl;
} }
@ -102,16 +99,16 @@ class DocumentModel extends Document
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl]))
{ {
// get extra keys of the module // get extra keys of the module
if(!isset($module_extra_keys[$module_srl])) if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
{ {
$module_extra_keys[$module_srl] = self::getExtraKeys($module_srl); $GLOBALS['XE_EXTRA_KEYS'][$module_srl] = self::getExtraKeys($module_srl);
} }
// set extra variables of the document // set extra variables of the document
if($module_extra_keys[$module_srl]) if(!empty($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
{ {
$document_extra_vars = array(); $document_extra_vars = array();
foreach($module_extra_keys[$module_srl] as $idx => $key) foreach($GLOBALS['XE_EXTRA_KEYS'][$module_srl] as $idx => $key)
{ {
$document_extra_vars[$idx] = clone($key); $document_extra_vars[$idx] = clone($key);