diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 42ce39634cd..13fb6e3d93b 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -11,6 +11,7 @@ Yii Framework 2 Change Log - Bug #20002: Fixed superfluous query on HEAD request in serializer (xicond) - Enh #12743: Added new methods `BaseActiveRecord::loadRelations()` and `BaseActiveRecord::loadRelationsFor()` to eager load related models for existing primary model instances (PowerGamer1) - Enh #20030: Improve performance of handling `ErrorHandler::$memoryReserveSize` (antonshevelev, rob006) +- Enh #20042: Add empty array check to `ActiveQueryTrait::findWith()` (renkas) - Enh #20032: Added `mask` method for string masking with multibyte support (salehhashemi1992) diff --git a/framework/db/ActiveQueryTrait.php b/framework/db/ActiveQueryTrait.php index e2de1dd12d9..d49fa0fba87 100644 --- a/framework/db/ActiveQueryTrait.php +++ b/framework/db/ActiveQueryTrait.php @@ -135,6 +135,10 @@ protected function createModels($rows) */ public function findWith($with, &$models) { + if (empty($models)) { + return; + } + $primaryModel = reset($models); if (!$primaryModel instanceof ActiveRecordInterface) { /* @var $modelClass ActiveRecordInterface */