Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorAndrejs Verza <andrejs.verza@zabbix.com>2021-05-08 12:15:40 +0300
committerAndrejs Verza <andrejs.verza@zabbix.com>2021-05-08 12:15:40 +0300
commitd7fe0ed56d9270a4e251b1234a601d3a67232abc (patch)
tree32ff1bb86a50ca9ac8e56e4f6cfba2c1415ea65d /ui
parent397c3159cf565daec25e0f28a447f74964655dcb (diff)
..F....... [ZBXNEXT-6544,ZBXNEXT-6561] fixed partial expression (condition) validation
Diffstat (limited to 'ui')
-rw-r--r--ui/app/controllers/CControllerPopupTriggerExpr.php4
-rw-r--r--ui/include/classes/validators/CExpressionValidator.php8
2 files changed, 7 insertions, 5 deletions
diff --git a/ui/app/controllers/CControllerPopupTriggerExpr.php b/ui/app/controllers/CControllerPopupTriggerExpr.php
index fb6847745b6..6687aa8533e 100644
--- a/ui/app/controllers/CControllerPopupTriggerExpr.php
+++ b/ui/app/controllers/CControllerPopupTriggerExpr.php
@@ -1079,7 +1079,7 @@ class CControllerPopupTriggerExpr extends CController {
protected function doAction() {
$expression_parser = new CExpressionParser(['lldmacros' => true]);
- $expression_validator = new CExpressionValidator();
+ $expression_validator = new CExpressionValidator(['partial' => true]);
$itemid = $this->getInput('itemid', 0);
$function = $this->getInput('function', 'last');
@@ -1415,7 +1415,7 @@ class CControllerPopupTriggerExpr extends CController {
// Parse and validate trigger expression.
if ($expression_parser->parse($data['expression']) == CParser::PARSE_SUCCESS) {
if (!$expression_validator->validate($expression_parser->getResult()->getTokens())) {
- error($expression_validator->getError());
+ error(_s('Invalid condition: %1$s.', $expression_validator->getError()));
}
}
else {
diff --git a/ui/include/classes/validators/CExpressionValidator.php b/ui/include/classes/validators/CExpressionValidator.php
index 52b1ba8d354..b8edd4b1ad2 100644
--- a/ui/include/classes/validators/CExpressionValidator.php
+++ b/ui/include/classes/validators/CExpressionValidator.php
@@ -29,11 +29,13 @@ class CExpressionValidator extends CValidator {
*
* Supported options:
* 'calculated' => false Validate expression as part of calculated item formula.
+ * 'partial' => false Validate partial expression (relaxed requirements).
*
* @var array
*/
private $options = [
- 'calculated' => false
+ 'calculated' => false,
+ 'partial' => false
];
/**
@@ -90,7 +92,7 @@ class CExpressionValidator extends CValidator {
}
if (!$this->options['calculated']) {
- if (!self::hasHistoryFunctions($tokens)) {
+ if (!$this->options['partial'] && !self::hasHistoryFunctions($tokens)) {
$this->setError(_('trigger expression must contain at least one /host/key reference'));
return false;
@@ -188,7 +190,7 @@ class CExpressionValidator extends CValidator {
}
/**
- * Check if history function tokens are contained within the hierarchy of given tokens.
+ * Check if there are history function tokens within the hierarchy of given tokens.
*
* @param array $tokens
*