Skip to content

Commit 7ae255c

Browse files
authored
Merge pull request #19949 from uaoleg/patch-2
PHP 8.1 trim(): Passing null to parameter #1 ($string) of type string is deprecated
2 parents 2995696 + fd5c1bb commit 7ae255c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Yii Framework 2 Change Log
77
- Bug #19925: Improved PHP version check when handling MIME types (schmunk42)
88
- Bug #19940: File Log writer without newline (terabytesoftw)
99
- Bug #19951: Removed unneeded MIME file tests (schmunk42)
10+
- Bug #19950: Fix `Query::groupBy(null)` causes error for PHP 8.1: `trim(): Passing null to parameter #1 ($string) of type string is deprecated`
1011

1112

1213
2.0.49 August 29, 2023

framework/db/Query.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ public function rightJoin($table, $on = '', $params = [])
10491049

10501050
/**
10511051
* Sets the GROUP BY part of the query.
1052-
* @param string|array|ExpressionInterface $columns the columns to be grouped by.
1052+
* @param string|array|ExpressionInterface|null $columns the columns to be grouped by.
10531053
* Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']).
10541054
* The method will automatically quote the column names unless a column contains some parenthesis
10551055
* (which means the column contains a DB expression).
@@ -1067,7 +1067,7 @@ public function groupBy($columns)
10671067
{
10681068
if ($columns instanceof ExpressionInterface) {
10691069
$columns = [$columns];
1070-
} elseif (!is_array($columns)) {
1070+
} elseif (!is_array($columns) && !is_null($columns)) {
10711071
$columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY);
10721072
}
10731073
$this->groupBy = $columns;

0 commit comments

Comments
 (0)