N°5389 - Email Notification templates with AttributeLinkedSetIndirect failed

This commit is contained in:
Eric Espie
2022-08-12 10:37:43 +02:00
parent f10e9c2d64
commit cc6cf79835

View File

@@ -3201,15 +3201,15 @@ abstract class DBObject implements iDisplay
// - TriggerOnObjectMention
$this->ActivateOnMentionTriggers(false);
$bHasANewExternalKeyValue = false;
$bNeedReload = false;
$aHierarchicalKeys = array();
$aDBChanges = array();
foreach ($aChanges as $sAttCode => $valuecurr)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsExternalKey())
if ($oAttDef->IsExternalKey() || $oAttDef->IsLinkSet())
{
$bHasANewExternalKeyValue = true;
$bNeedReload = true;
}
if ($oAttDef->IsBasedOnDBColumns())
{
@@ -3367,24 +3367,10 @@ abstract class DBObject implements iDisplay
$this->m_aModifiedAtt = array();
try {
// - TriggerOnObjectUpdate
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObjectUpdate AS t WHERE t.target_class IN (:class_list)"),
array(), $aParams);
while ($oTrigger = $oSet->Fetch()) {
/** @var \TriggerOnObjectUpdate $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
$this->AfterUpdate();
// Reload to get the external attributes
if ($bHasANewExternalKeyValue) {
if ($bNeedReload) {
$this->Reload(true /* AllowAllData */);
} else {
// Reset original values although the object has not been reloaded
@@ -3397,6 +3383,20 @@ abstract class DBObject implements iDisplay
}
}
}
// - TriggerOnObjectUpdate
$aParams = array('class_list' => MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT TriggerOnObjectUpdate AS t WHERE t.target_class IN (:class_list)'),
array(), $aParams);
while ($oTrigger = $oSet->Fetch()) {
/** @var \TriggerOnObjectUpdate $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);
}
}
}
catch (Exception $e)
{