EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
function runtime error
Yuriifa89cdf4264d
diff --git a/application/Espo/Core/Formula/Exceptions/FunctionRuntimeError.php b/application/Espo/Core/Formula/Exceptions/FunctionRuntimeError.phpnew file mode 100644index 0000000000..4245c6f174--- /dev/null+++ b/application/Espo/Core/Formula/Exceptions/FunctionRuntimeError.php@@ -0,0 +1,38 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Core\Formula\Exceptions;++/**+ * For various errors happened inside a function in runtime.+ *.+ * @since 9.4.0+ */+class FunctionRuntimeError extends Error+{}diff --git a/application/Espo/Core/Formula/Functions/ArrayGroup/AtType.php b/application/Espo/Core/Formula/Functions/ArrayGroup/AtType.phpindex acc80da142..951c3e1e18 100644--- a/application/Espo/Core/Formula/Functions/ArrayGroup/AtType.php+++ b/application/Espo/Core/Formula/Functions/ArrayGroup/AtType.php@@ -29,10 +29,9 @@namespace Espo\Core\Formula\Functions\ArrayGroup;-use Espo\Core\Formula\{- Functions\BaseFunction,- ArgumentList,-};+use Espo\Core\Formula\ArgumentList;+use Espo\Core\Formula\Exceptions\FunctionRuntimeError;+use Espo\Core\Formula\Functions\BaseFunction;class AtType extends BaseFunction{@@ -56,8 +55,7 @@ class AtType extends BaseFunction}if (!array_key_exists($index, $array)) {- $this->log("index doesn't exist");- return null;+ throw new FunctionRuntimeError("Cannot access array value by non-existing index $index.");}return $array[$index];diff --git a/application/Espo/Core/Formula/Processor.php b/application/Espo/Core/Formula/Processor.phpindex 3260a11f98..e77f7820b5 100644--- a/application/Espo/Core/Formula/Processor.php+++ b/application/Espo/Core/Formula/Processor.php@@ -32,6 +32,7 @@ namespace Espo\Core\Formula;use Espo\Core\Formula\Exceptions\BadArgumentType;use Espo\Core\Formula\Exceptions\BadArgumentValue;use Espo\Core\Formula\Exceptions\ExecutionException;+use Espo\Core\Formula\Exceptions\FunctionRuntimeError;use Espo\Core\Formula\Exceptions\TooFewArguments;use Espo\Core\Formula\Exceptions\UndefinedKey;use Espo\Core\Formula\Functions\Base as DeprecatedBaseFunction;@@ -107,6 +108,10 @@ class Processorreturn $function->process($item->getArgumentList());} catch (UndefinedKey $e) {throw UndefinedKey::cloneWithLevelRisen($e);+ } catch (FunctionRuntimeError $e) {+ $message = sprintf('Function %s; %s', $item->getType(), $e->getMessage());++ throw new Error($message);}}@@ -186,6 +191,10 @@ class Processor} catch (TooFewArguments|BadArgumentType|BadArgumentValue $e) {$message = sprintf('Function %s; %s', $item->getType(), $e->getLogMessage());+ throw new Error($message);+ } catch (FunctionRuntimeError $e) {+ $message = sprintf('Function %s; %s', $item->getType(), $e->getMessage());+throw new Error($message);}}