Skip to content

Commit 366840e

Browse files
committed
SqlPreprocessor::formatValue() rejects array unless they are explicitly allowed (possible BC break)
1 parent 93bb692 commit 366840e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Database/SqlPreprocessor.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function formatValue($value, string $mode = null): string
194194
$value = iterator_to_array($value);
195195
}
196196

197-
if (is_array($value)) {
197+
if ($mode && is_array($value)) {
198198
$vx = $kx = [];
199199
if ($mode === self::MODE_AUTO) {
200200
$mode = $this->arrayMode;
@@ -229,7 +229,7 @@ private function formatValue($value, string $mode = null): string
229229
} elseif (!$mode || $mode === self::MODE_SET) {
230230
foreach ($value as $k => $v) {
231231
if (is_int($k)) { // value, value, ... OR (1, 2), (3, 4)
232-
$vx[] = is_array($v) ? '(' . $this->formatValue($v) . ')' : $this->formatValue($v);
232+
$vx[] = is_array($v) ? '(' . $this->formatValue($v, self::MODE_LIST) . ')' : $this->formatValue($v);
233233
} elseif (substr($k, -1) === '=') { // key+=value, key-=value, ...
234234
$k2 = $this->delimite(substr($k, 0, -2));
235235
$vx[] = $k2 . '=' . $k2 . ' ' . substr($k, -2, 1) . ' ' . $this->formatValue($v);
@@ -255,7 +255,7 @@ private function formatValue($value, string $mode = null): string
255255
$k = $this->delimite($k);
256256
if (is_array($v)) {
257257
if ($v) {
258-
$vx[] = $k . ' ' . ($operator ? $operator . ' ' : '') . 'IN (' . $this->formatValue(array_values($v)) . ')';
258+
$vx[] = $k . ' ' . ($operator ? $operator . ' ' : '') . 'IN (' . $this->formatValue(array_values($v), self::MODE_LIST) . ')';
259259
} elseif ($operator === 'NOT') {
260260
} else {
261261
$vx[] = '1=0';

0 commit comments

Comments
 (0)