EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
setInContainerNotWritten
Yuri Kuznetsov7f4bc6f9528f
diff --git a/application/Espo/Core/ORM/Entity.php b/application/Espo/Core/ORM/Entity.phpindex 958667cc7b..567eec148f 100644--- a/application/Espo/Core/ORM/Entity.php+++ b/application/Espo/Core/ORM/Entity.php@@ -207,6 +207,7 @@ class Entity extends BaseEntity** @param ?array<string, string> $columns Deprecated as of v9.0.* @todo Add a method to load and set only fetched values?+ * @internal*/public function loadLinkMultipleField(string $field, ?array $columns = null): void{@@ -302,8 +303,8 @@ class Entity extends BaseEntity$toSetFetched = !$this->isNew() && !$this->hasFetched($idsAttribute);- $this->set($idsAttribute, $ids);- $this->set($namesAttribute, $names);+ $this->setInContainerNotWritten($idsAttribute, $ids);+ $this->setInContainerNotWritten($namesAttribute, $names);if ($toSetFetched) {$this->setFetched($idsAttribute, $ids);@@ -319,7 +320,7 @@ class Entity extends BaseEntity}if ($columns) {- $this->set($columnsAttribute, $columnsData);+ $this->setInContainerNotWritten($columnsAttribute, $columnsData);if ($toSetFetched) {$this->setFetched($columnsAttribute, $columnsData);@@ -350,7 +351,6 @@ class Entity extends BaseEntity$select = [Attribute::ID, Field::NAME];$entity = $this->entityManager- ->getRDBRepository($this->getEntityType())->getRelation($this, $field)->select($select)->findOne();@@ -375,8 +375,8 @@ class Entity extends BaseEntityreturn;}- $this->set($idAttribute, $entityId);- $this->set($nameAttribute, $entityName);+ $this->setInContainerNotWritten($idAttribute, $entityId);+ $this->setInContainerNotWritten($nameAttribute, $entityName);}/**diff --git a/application/Espo/ORM/BaseEntity.php b/application/Espo/ORM/BaseEntity.phpindex 6f29aa9264..9ee2cee762 100644--- a/application/Espo/ORM/BaseEntity.php+++ b/application/Espo/ORM/BaseEntity.php@@ -274,16 +274,28 @@ class BaseEntity implements Entity}/**- * Set a value in the container.- *- * @param mixed $value+ * Set a value in the container. To be used wisely. Use `set` instead.*/- protected function setInContainer(string $attribute, $value): void+ protected function setInContainer(string $attribute, mixed $value): void{$this->valuesContainer[$attribute] = $value;+$this->writtenMap[$attribute] = true;}+ /**+ * Not to be used. To be used internally for lazy-loading purpose.+ *+ * @internal+ * @since 9.1.0+ */+ protected function setInContainerNotWritten(string $attribute, mixed $value): void+ {+ $this->valuesContainer[$attribute] = $value;++ unset($this->writtenMap[$attribute]);+ }+/*** Whether an attribute is set in the container.*/