N°5389 - Email Notification templates with AttributeLinkedSetIndirect failed

This commit is contained in:
Eric Espie
2022-09-19 15:30:24 +02:00
parent 71464f6d0e
commit aa31da34e5
4 changed files with 20 additions and 30 deletions

View File

@@ -3201,19 +3201,14 @@ abstract class DBObject implements iDisplay
// - TriggerOnObjectMention
$this->ActivateOnMentionTriggers(false);
$bNeedReload = false;
$aHierarchicalKeys = array();
$aDBChanges = array();
foreach ($aChanges as $sAttCode => $valuecurr)
foreach ($aChanges as $sAttCode => $currentValue)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsExternalKey() || $oAttDef->IsLinkSet())
{
$bNeedReload = true;
}
if ($oAttDef->IsBasedOnDBColumns())
{
$aDBChanges[$sAttCode] = $aChanges[$sAttCode];
$aDBChanges[$sAttCode] = $currentValue;
}
if ($oAttDef->IsHierarchicalKey())
{
@@ -3366,18 +3361,11 @@ abstract class DBObject implements iDisplay
$this->EventUpdateAfter(['changes' => $aChanges]);
$this->AfterUpdate();
// Reload to get the external attributes
if ($bNeedReload) {
$this->Reload(true /* AllowAllData */);
} else {
// Reset original values although the object has not been reloaded
foreach ($this->m_aLoadedAtt as $sAttCode => $bLoaded)
{
if ($bLoaded)
{
$value = $this->m_aCurrValues[$sAttCode];
$this->m_aOrigValues[$sAttCode] = is_object($value) ? clone $value : $value;
}
// Reset original values although the object has not been reloaded
foreach ($this->m_aLoadedAtt as $sAttCode => $bLoaded) {
if ($bLoaded) {
$value = $this->m_aCurrValues[$sAttCode];
$this->m_aOrigValues[$sAttCode] = is_object($value) ? clone $value : $value;
}
}
@@ -3388,7 +3376,7 @@ abstract class DBObject implements iDisplay
while ($oTrigger = $oSet->Fetch()) {
/** @var \TriggerOnObjectUpdate $oTrigger */
try {
$oTrigger->DoActivate($this->ToArgs('this'));
$oTrigger->DoActivate($this->ToArgs());
}
catch (Exception $e) {
utils::EnrichRaisedException($oTrigger, $e);

View File

@@ -383,9 +383,8 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
$iPreservedCount = count($this->aPreserved);
if ($this->iCursor < $iPreservedCount)
{
$iRet = current($this->aPreserved);
$this->oOriginalSet->Seek($iRet);
$oRet = $this->oOriginalSet->Fetch();
$sId = key($this->aPreserved);
$oRet = MetaModel::GetObject($this->sClass, $sId);
}
else
{