diff --git a/application/Espo/Entities/LayoutRecord.php b/application/Espo/Entities/LayoutRecord.php index 911ef2730d..5c41f07ed8 100644 --- a/application/Espo/Entities/LayoutRecord.php +++ b/application/Espo/Entities/LayoutRecord.php @@ -29,23 +29,7 @@ namespace Espo\Entities; -use Espo\Core\Utils\Json; - class LayoutRecord extends \Espo\Core\ORM\Entity { public const ENTITY_TYPE = 'LayoutRecord'; - - /*protected function _getData() - { - $data = $this->getFromContainer('data'); - - return Json::decode($data); - } - - protected function _setData($value) - { - $data = Json::encode($value); - - $this->setInContainer('data', $data); - }*/ } diff --git a/application/Espo/Services/Layout.php b/application/Espo/Services/Layout.php index 4488ef9ccd..bd2606a7aa 100644 --- a/application/Espo/Services/Layout.php +++ b/application/Espo/Services/Layout.php @@ -117,14 +117,17 @@ class Layout $layout = $this->getRecordFromSet($scope, $name, $setId, true); if ($layout && $layout->get('data') !== null) { - $result = Json::decode($layout->get('data')); + /** @var string */ + $data = $layout->get('data'); + + $result = Json::decode($data); } } if (!$result) { - $result = Json::decode( - $this->layout->get($scope, $name) - ); + $data = $this->layout->get($scope, $name) ?? 'false'; + + $result = Json::decode($data); } if ($result === false) { @@ -205,12 +208,12 @@ class Layout } if (!$data) { - $dataString = $this->layout->get($scope, $name); + $dataString = $this->layout->get($scope, $name) ?? 'null'; - $data = json_decode($dataString); + $data = Json::decode($dataString); } else { - $dataString = json_encode($data); + $dataString = Json::encode($data); } if (is_null($data)) { @@ -302,7 +305,7 @@ class Layout $layout = $this->getRecordFromSet($scope, $name, $setId); if (!$layout) { - $layout = $this->entityManager->getEntity('LayoutRecord'); + $layout = $this->entityManager->getNewEntity('LayoutRecord'); $layout->set([ 'layoutSetId' => $setId, diff --git a/application/Espo/Services/LeadCapture.php b/application/Espo/Services/LeadCapture.php index 6e9ad5f67c..b62dac7c3f 100644 --- a/application/Espo/Services/LeadCapture.php +++ b/application/Espo/Services/LeadCapture.php @@ -88,7 +88,7 @@ class LeadCapture extends Record } } - $seed = $this->getEntityManager()->getEntity('Lead'); + $seed = $this->getEntityManager()->getNewEntity('Lead'); foreach ($attributeList as $i => $attribute) { $value = strtoupper(Util::camelCaseToUnderscore($attribute)); diff --git a/application/Espo/Services/Note.php b/application/Espo/Services/Note.php index 29cfab19e1..f0998ac3be 100644 --- a/application/Espo/Services/Note.php +++ b/application/Espo/Services/Note.php @@ -214,8 +214,11 @@ class Note extends Record $userTeamIdList = $this->user->getTeamIdList(); + /** @var string[] */ $userIdList = $entity->getLinkMultipleIdList('users'); + /** @var string[] */ $portalIdList = $entity->getLinkMultipleIdList('portals'); + /** @var string[] */ $teamIdList = $entity->getLinkMultipleIdList('teams'); /** @var iterable $targetUserList */ diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index 9f83479625..53a2bec8af 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -156,7 +156,7 @@ class Pdf $filename = Util::sanitizeFileName($name) . '.pdf'; - $attachment = $this->entityManager->getEntity('Attachment'); + $attachment = $this->entityManager->getNewEntity('Attachment'); $attachment->set([ 'name' => $filename, @@ -260,7 +260,7 @@ class Pdf $filename = Util::sanitizeFileName($entityTypeTranslated) . '.pdf'; - $attachment = $this->entityManager->getEntity('Attachment'); + $attachment = $this->entityManager->getNewEntity('Attachment'); $attachment->set([ 'name' => $filename, @@ -271,7 +271,7 @@ class Pdf $this->entityManager->saveEntity($attachment); - $job = $this->entityManager->getEntity('Job'); + $job = $this->entityManager->getNewEntity('Job'); $job->set([ 'serviceName' => 'Pdf', @@ -316,7 +316,11 @@ class Pdf $params = Params::create()->withAcl(); } - return $this->buildFromTemplateInternal($entity, $template, false, null, $params, $data); + $result = $this->buildFromTemplateInternal($entity, $template, false, null, $params, $data); + + assert($result !== null); + + return $result; } /**