Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsov2e0f0fb7db73
diff --git a/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php b/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php
index 60fe30bb5c..64c74aa7fd 100644
--- a/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php
+++ b/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php
@@ -57,6 +57,14 @@ class VariableGetValueByKeyType extends BaseFunction
$reference =& $this->getVariables()->$name;
+ return $this->getByKey($reference, $key);
+ }
+
+ /**
+ * @throws Error
+ */
+ private function getByKey(mixed &$reference, mixed $key): mixed
+ {
if (!is_array($reference) && !$reference instanceof stdClass) {
throw new Error("Cannot access by key of variable that is non-array and non-object.");
}
diff --git a/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php b/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php
index 5fe8a0b7a3..50af12519a 100644
--- a/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php
+++ b/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php
@@ -58,6 +58,14 @@ class VariableSetKeyValueType extends BaseFunction
$reference =& $this->getVariables()->$name;
+ $this->setByKey($reference, $key, $value);
+ }
+
+ /**
+ * @throws Error
+ */
+ private function setByKey(mixed &$reference, mixed $key, mixed $value): void
+ {
if (!is_array($reference) && !$reference instanceof stdClass) {
throw new Error("Cannot access by key of variable that is non-array and non-object.");
}