diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 2c0a4c767b..67fa7d4a6d 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -91,6 +91,7 @@ Yii Framework 2 Change Log - Bug #4880: Return value of yii\web\Request::getPrefferedLanguage() was a normalized value instead of a valid language value from the input array (cebe) - Bug #4920: `yii\filters\auth\CompositeAuth` should not trigger error as long as one of the methods succeeds (qiangxue) - Bug #4954: MSSQL column comments are not retrieved correctly (SerjRamone) +- Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) - Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul) - Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue) diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index 8d781a9faf..e68fe6d1c5 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -482,9 +482,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface $relations[$fullName] = $relation = $primaryModel->getRelation($name); if ($callback !== null) { call_user_func($callback, $relation); - if(is_array($relation->joinWith)) { - $relation->buildJoinWith(); - } + } + if (!empty($relation->joinWith)) { + $relation->buildJoinWith(); } $this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName)); } diff --git a/tests/unit/framework/db/ActiveRecordTest.php b/tests/unit/framework/db/ActiveRecordTest.php index 63584548cd..ca9b9e976f 100644 --- a/tests/unit/framework/db/ActiveRecordTest.php +++ b/tests/unit/framework/db/ActiveRecordTest.php @@ -601,7 +601,7 @@ class ActiveRecordTest extends DatabaseTestCase $model->char_col = '1337'; $model->char_col2 = 'test'; $model->char_col3 = 'test123'; - $model->float_col = 1337.42; + $model->float_col = 3.742; $model->float_col2 = 42.1337; $model->bool_col = true; $model->bool_col2 = false;