diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index 26efeb1d3..596823041 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -839,12 +839,15 @@ class MatchExpression extends BinaryExpression * MatchExpression constructor. * * @param \FieldExpression $oLeftExpr - * @param \ScalarExpression $oRightExpr + * @param \Expression $oRightExpr * * @throws \CoreException */ - public function __construct(FieldExpression $oLeftExpr, ScalarExpression $oRightExpr) + public function __construct(FieldExpression $oLeftExpr, Expression $oRightExpr) { + if (!$oRightExpr instanceof ScalarExpression && !$oRightExpr instanceof VariableExpression) { + throw new CoreException('Only instance of ScalarExpression or VariableExpression are allowed in MATCHES '.get_class( $oRightExpr).' found', $oRightExpr); + } parent::__construct($oLeftExpr, 'MATCHES', $oRightExpr); } diff --git a/core/oql/oql-parser.php b/core/oql/oql-parser.php index d2f752da4..c67ffff7a 100644 --- a/core/oql/oql-parser.php +++ b/core/oql/oql-parser.php @@ -1600,38 +1600,38 @@ static public $yy_action = array( $this->_retvalue = new ListOqlExpression($this->yystack[$this->yyidx + -1]->minor); } #line 1606 "..\oql-parser.php" -#line 132 "..\oql-parser.y" +#line 131 "..\oql-parser.y" function yy_r43(){ $this->_retvalue = new NestedQueryOqlExpression($this->yystack[$this->yyidx + -1]->minor); } #line 1611 "..\oql-parser.php" -#line 147 "..\oql-parser.y" +#line 146 "..\oql-parser.y" function yy_r47(){ $this->_retvalue = array(); } #line 1616 "..\oql-parser.php" -#line 158 "..\oql-parser.y" +#line 157 "..\oql-parser.y" function yy_r51(){ $this->_retvalue = new IntervalOqlExpression($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); } #line 1619 "..\oql-parser.php" -#line 171 "..\oql-parser.y" +#line 170 "..\oql-parser.y" function yy_r61(){ $this->_retvalue = new ScalarOqlExpression($this->yystack[$this->yyidx + 0]->minor); } #line 1622 "..\oql-parser.php" -#line 173 "..\oql-parser.y" +#line 172 "..\oql-parser.y" function yy_r63(){ $this->_retvalue = new ScalarOqlExpression(null); } #line 1625 "..\oql-parser.php" -#line 175 "..\oql-parser.y" +#line 174 "..\oql-parser.y" function yy_r64(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor); } #line 1628 "..\oql-parser.php" -#line 176 "..\oql-parser.y" +#line 175 "..\oql-parser.y" function yy_r65(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -2]->minor); } #line 1631 "..\oql-parser.php" -#line 177 "..\oql-parser.y" +#line 176 "..\oql-parser.y" function yy_r66(){ $this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; } #line 1634 "..\oql-parser.php" -#line 180 "..\oql-parser.y" +#line 179 "..\oql-parser.y" function yy_r67(){ $this->_retvalue = new VariableOqlExpression(substr($this->yystack[$this->yyidx + 0]->minor, 1)); } #line 1637 "..\oql-parser.php" -#line 182 "..\oql-parser.y" +#line 181 "..\oql-parser.y" function yy_r68(){ if ($this->yystack[$this->yyidx + 0]->minor[0] == '`') { @@ -1644,19 +1644,19 @@ static public $yy_action = array( $this->_retvalue = new OqlName($name, $this->m_iColPrev); } #line 1650 "..\oql-parser.php" -#line 193 "..\oql-parser.y" +#line 192 "..\oql-parser.y" function yy_r69(){$this->_retvalue=(int)$this->yystack[$this->yyidx + 0]->minor; } #line 1653 "..\oql-parser.php" -#line 194 "..\oql-parser.y" +#line 193 "..\oql-parser.y" function yy_r70(){$this->_retvalue=(int)-$this->yystack[$this->yyidx + 0]->minor; } #line 1656 "..\oql-parser.php" -#line 195 "..\oql-parser.y" +#line 194 "..\oql-parser.y" function yy_r71(){$this->_retvalue=new OqlHexValue($this->yystack[$this->yyidx + 0]->minor); } #line 1659 "..\oql-parser.php" -#line 196 "..\oql-parser.y" +#line 195 "..\oql-parser.y" function yy_r72(){$this->_retvalue=stripslashes(substr($this->yystack[$this->yyidx + 0]->minor, 1, strlen($this->yystack[$this->yyidx + 0]->minor) - 2)); } #line 1662 "..\oql-parser.php" -#line 199 "..\oql-parser.y" +#line 198 "..\oql-parser.y" function yy_r73(){$this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; } #line 1665 "..\oql-parser.php" @@ -1940,7 +1940,7 @@ throw new OQLParserException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCo } while ($yymajor != self::YYNOCODE && $this->yyidx >= 0); } } -#line 264 "..\oql-parser.y" +#line 263 "..\oql-parser.y" class OQLParserException extends OQLException diff --git a/core/oql/oqlquery.class.inc.php b/core/oql/oqlquery.class.inc.php index bc357c0c5..6a4bd5cd8 100644 --- a/core/oql/oqlquery.class.inc.php +++ b/core/oql/oqlquery.class.inc.php @@ -173,7 +173,7 @@ class MatchOqlExpression extends MatchExpression implements CheckableExpression throw new OqlNormalizeException('Only "field MATCHES string" syntax is allowed', $sSourceQuery, new OqlName($this->m_oLeftExpr->RenderExpression(true), 0)); } // Only field MATCHES scalar is allowed - if (!$this->m_oRightExpr instanceof ScalarExpression) + if (!$this->m_oRightExpr instanceof ScalarExpression && !$this->m_oRightExpr instanceof VariableOqlExpression) { throw new OqlNormalizeException('Only "field MATCHES string" syntax is allowed', $sSourceQuery, new OqlName($this->m_oRightExpr->RenderExpression(true), 0)); } diff --git a/core/oql/version.txt b/core/oql/version.txt index 3c8103be0..26a3e601d 100644 --- a/core/oql/version.txt +++ b/core/oql/version.txt @@ -1 +1 @@ -2019-12-03 \ No newline at end of file +2020-09-29 \ No newline at end of file diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 805f9f336..7bbe8e815 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -609,9 +609,9 @@ class CheckStopWatchThresholds implements iBackgroundProcess $sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL)); $oTriggerSet = new DBObjectSet( - DBObjectSearch::FromOQL("SELECT TriggerOnThresholdReached AS t WHERE t.target_class IN ('$sClassList') AND stop_watch_code MATCHES '$sAttCode' AND threshold_index = :threshold_index"), + DBObjectSearch::FromOQL("SELECT TriggerOnThresholdReached AS t WHERE t.target_class IN ('$sClassList') AND stop_watch_code MATCHES :stop_watch_code AND threshold_index = :threshold_index"), array(), // order by - array('threshold_index' => $iThreshold) + array('stop_watch_code' => $sAttCode, 'threshold_index' => $iThreshold) ); while ($oTrigger = $oTriggerSet->Fetch()) {