Skip to content

Commit

Permalink
Do not inappropriately register bind when the value is a closure
Browse files Browse the repository at this point in the history
Such closure just has nothing to do in the $binds array.

The code currently works because the binds compiler determines the binds to apply not by looking at the $binds array, but by looking at the query string, so it doesn't reach the closure.

If we modify the binds compiler to instead look at the $binds array (which makes more sense), it would attempt to replace this registered named bind in the query string, and trying to replace with a closure would trigger a "cannot cast to string" error.
  • Loading branch information
vlakoff committed Nov 5, 2021
1 parent 699129b commit 223ca28
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,6 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
}
}

$bind = $this->setBind($k, $v, $escape);

if (empty($op)) {
$op = ' =';
} else {
Expand All @@ -675,7 +673,8 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
$builder = $this->cleanClone();
$v = '(' . str_replace("\n", ' ', $v($builder)->getCompiledSelect()) . ')';
} else {
$v = " :{$bind}:";
$bind = $this->setBind($k, $v, $escape);
$v = " :{$bind}:";
}
} elseif (! $this->hasOperator($k) && $qbKey !== 'QBHaving') {
// value appears not to have been set, assign the test to IS NULL
Expand Down

0 comments on commit 223ca28

Please sign in to comment.