From b05ad49a1943ca2f876ed23658d523cabf8b33a2 Mon Sep 17 00:00:00 2001 From: Oleg Poludnenko Date: Mon, 11 Sep 2023 19:38:41 +0300 Subject: [PATCH 1/2] trim(): Passing null to parameter #1 ($string) of type string is deprecated --- framework/db/Query.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/db/Query.php b/framework/db/Query.php index f0b215859dc..1819c9c3107 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -1049,7 +1049,7 @@ public function rightJoin($table, $on = '', $params = []) /** * Sets the GROUP BY part of the query. - * @param string|array|ExpressionInterface $columns the columns to be grouped by. + * @param string|array|ExpressionInterface|null $columns the columns to be grouped by. * Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']). * The method will automatically quote the column names unless a column contains some parenthesis * (which means the column contains a DB expression). @@ -1067,7 +1067,7 @@ public function groupBy($columns) { if ($columns instanceof ExpressionInterface) { $columns = [$columns]; - } elseif (!is_array($columns)) { + } elseif (!is_array($columns) && !is_null($columns)) { $columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY); } $this->groupBy = $columns; From fd5c1bbf275702e88012bcedd22f0af86de2ba1f Mon Sep 17 00:00:00 2001 From: Oleg Poludnenko Date: Wed, 20 Sep 2023 12:27:33 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e468b61f786..e2eefa083b9 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -7,6 +7,7 @@ Yii Framework 2 Change Log - Bug #19925: Improved PHP version check when handling MIME types (schmunk42) - Bug #19940: File Log writer without newline (terabytesoftw) - Bug #19951: Removed unneeded MIME file tests (schmunk42) +- Bug #19950: Fix `Query::groupBy(null)` causes error for PHP 8.1: `trim(): Passing null to parameter #1 ($string) of type string is deprecated` 2.0.49 August 29, 2023