From 27b1b1f8a84b0ba76c3183d2e21c10dcf60f33b8 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 21 Dec 2018 09:59:19 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01903=20-=20Fix=20initial=20value=20of=20?= =?UTF-8?q?a=20MetaEnum=20attribute=20is=20always=20its=20default=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index d5793db2f..e9a767248 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -148,6 +148,31 @@ abstract class DBObject implements iDisplay $this->m_aLoadedAtt[$sAttCode] = true; } } + + $this->UpdateMetaAttributes(); + } + + /** + * Update meta-attributes depending on the given attribute list + * + * @param array|null $aAttCodes List of att codes + * + * @throws \CoreException + */ + protected function UpdateMetaAttributes($aAttCodes = null) + { + if (is_null($aAttCodes)) + { + $aAttCodes = MetaModel::GetAttributesList(get_class($this)); + } + foreach ($aAttCodes as $sAttCode) + { + foreach (MetaModel::ListMetaAttributes(get_class($this), $sAttCode) as $sMetaAttCode => $oMetaAttDef) + { + /** @var \AttributeMetaEnum $oMetaAttDef */ + $this->_Set($sMetaAttCode, $oMetaAttDef->MapValue($this)); + } + } } // Read-only <=> Written once (archive) @@ -432,11 +457,7 @@ abstract class DBObject implements iDisplay } $this->_Set($sAttCode, $realvalue); - foreach (MetaModel::ListMetaAttributes(get_class($this), $sAttCode) as $sMetaAttCode => $oMetaAttDef) - { - /** @var \AttributeMetaEnum $oMetaAttDef */ - $this->_Set($sMetaAttCode, $oMetaAttDef->MapValue($this)); - } + $this->UpdateMetaAttributes(array($sAttCode)); // The object has changed, reset caches $this->m_bCheckStatus = null;