From cc6cf798357f7a4eb0ee891bdf5789b10bb8d8d6 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 12 Aug 2022 10:37:43 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05389=20-=20Email=20Notification=20templa?= =?UTF-8?q?tes=20with=20AttributeLinkedSetIndirect=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 4bc39209a..92836a043 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -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) {