diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 4851cee7a0..cb3f197dd4 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -223,15 +223,34 @@ class Metadata } /** - * Set Metadata data. + * Set metadata. Will be merged with the current data. * * @param array|scalar|null $data */ public function set(string $key1, string $key2, $data): void { - if (is_array($data)) { + $this->setInternal($key1, $key2, $data); + } + + /** + * Set a first-level param. Allows setting empty arrays. + * + * @since 8.0.6 + */ + public function setParam(string $key1, string $key2, string $param, mixed $value): void + { + $this->setInternal($key1, $key2, [$param => $value], true); + } + + /** + * @param array|scalar|null $data + */ + private function setInternal(string $key1, string $key2, $data, bool $allowEmptyArray = false): void + { + if (!$allowEmptyArray && is_array($data)) { foreach ($data as $key => $item) { if (is_array($item) && empty($item)) { + // @todo Revise. unset($data[$key]); } } diff --git a/application/Espo/Tools/EntityManager/EntityManager.php b/application/Espo/Tools/EntityManager/EntityManager.php index 0a3f577f4f..fe7c0e8f9f 100644 --- a/application/Espo/Tools/EntityManager/EntityManager.php +++ b/application/Espo/Tools/EntityManager/EntityManager.php @@ -726,7 +726,7 @@ class EntityManager $value = $data[$param]; - $this->metadata->set($location, $entityType, [$param => $value]); + $this->metadata->setParam($location, $entityType, $param, $value); } }