Fix #2217 call getDocumentList (after) trigger even if there are no results

This commit is contained in:
Kijin Sung 2023-11-28 00:06:21 +09:00
parent 4a2ea92f07
commit c2311f88be

View file

@ -265,26 +265,29 @@ class DocumentModel extends Document
$output = executeQueryArray($query_id, $args, $args->columnList); $output = executeQueryArray($query_id, $args, $args->columnList);
} }
// Return if no result or an error occurs // Return if there was an error.
if(!$output->toBool() || !$result = $output->data) if (!$output->toBool())
{ {
return $output; return $output;
} }
$output->data = array(); // Create document objects and load extra vars.
foreach($result as $key => $attribute) if ($output->data)
{ {
if(!isset($GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl])) foreach ($output->data as $key => $attribute)
{ {
$oDocument = new documentItem(); if (!isset($GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]))
$oDocument->setAttribute($attribute, false); {
$oDocument = new DocumentItem();
$oDocument->setAttribute($attribute, false);
}
$output->data[$key] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl];
} }
$output->data[$key] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl];
}
if($load_extra_vars) if ($load_extra_vars)
{ {
self::setToAllDocumentExtraVars(); self::setToAllDocumentExtraVars();
}
} }
// Call trigger (after) // Call trigger (after)