Skip to content

Commit

Permalink
Merge pull request #19949 from uaoleg/patch-2
Browse files Browse the repository at this point in the history
PHP 8.1 trim(): Passing null to parameter #1 ($string) of type string is deprecated
  • Loading branch information
bizley committed Sep 20, 2023
2 parents 2995696 + fd5c1bb commit 7ae255c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions framework/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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;
Expand Down

0 comments on commit 7ae255c

Please sign in to comment.