Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: prevent bound parameters being
[null]
when no parameters are g…
…iven to `Predicate#expression()` Around `laminas/laminas-db:2.10.1`, a regression was introduced, in which calling `Laminas\Db\Sql\Predicate#expression("an_expression()")` led to crashes like following in downstream consumers: ``` Laminas\Db\Sql\Exception\RuntimeException: The number of replacements in the expression does not match the number of parameters vendor/laminas/laminas-db/src/Sql/Expression.php:151 vendor/laminas/laminas-db/src/Sql/Predicate/PredicateSet.php:178 vendor/laminas/laminas-db/src/Sql/Predicate/PredicateSet.php:178 vendor/laminas/laminas-db/src/Sql/Predicate/PredicateSet.php:178 vendor/laminas/laminas-db/src/Sql/AbstractSql.php:129 vendor/laminas/laminas-db/src/Sql/Select.php:633 ``` This was because predicates were initialized with an `array{null}` by default, when expressions like `$sql->where->expression("some_expression()")` were used. The usage of `$sql->where->expression("some_expression()", "foo")` remains unchanged with this patch. This fix targets `2.15.x`, and attempts to make predicates safe to use when no parameters have been given. While an existing test has indeed been changed, this shouldn't have any effect for downstream consumers, since `Predicate#expression(string)` didn't work (so far) anyway, due to the kind of crash highlighted above.
- Loading branch information