From 080ab488fa2f62c6124d613f8571423cc0d47b75 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 18 Oct 2019 11:11:55 +0300 Subject: [PATCH] fix json object save --- application/Espo/ORM/Entity.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/application/Espo/ORM/Entity.php b/application/Espo/ORM/Entity.php index 81f384ecd2..6b5d92a2c9 100644 --- a/application/Espo/ORM/Entity.php +++ b/application/Espo/ORM/Entity.php @@ -448,6 +448,9 @@ abstract class Entity implements IEntity public function setFetched($name, $value) { + if ($this->getAttributeType($name) === self::JSON_OBJECT && $value) { + $value = unserialize(serialize($value)); + } $this->fetchedValuesContainer[$name] = $value; } @@ -478,12 +481,18 @@ abstract class Entity implements IEntity public function updateFetchedValues() { $this->fetchedValuesContainer = $this->valuesContainer; + + foreach ($this->fetchedValuesContainer as $attribute => $value) { + if ($this->getAttributeType($attribute) === self::JSON_OBJECT && $value) { + $this->fetchedValuesContainer[$attribute] = unserialize(serialize($value)); + } + } } public function setAsFetched() { $this->isFetched = true; - $this->fetchedValuesContainer = $this->valuesContainer; + $this->updateFetchedValues(); } public function setAsNotFetched()