Browse Source

Revert "Fixes #16552: Added check in `yii\db\ActiveQuery::prepare()` to prevent populating already populated relation when another relation is requested with `via`"

This reverts commit f69612f792.
tags/2.0.16
Alexander Makarov 6 years ago
parent
commit
cd442339df
No known key found for this signature in database
GPG Key ID: 3617B79C6A325E4A
  1. 1
      framework/CHANGELOG.md
  2. 16
      framework/db/ActiveQuery.php

1
framework/CHANGELOG.md

@ -44,7 +44,6 @@ Yii Framework 2 Change Log
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
- Bug #16514: Fixed `yii\di\Container::resolveCallableDependencies` to support callable object (wi1dcard)
- Bug #15889: Fixed override `yii\helpers\Html::setActivePlaceholder` (lesha724)
- Bug #16552: Added check in `yii\db\ActiveQuery::prepare()` to prevent populating already populated relation when another relation is requested with `via` (drlibra)
- Enh #16522: Allow jQuery 3.3 (Slamdunk)
- Enh #16603: Added `yii\mutex\FileMutex::$isWindows` for Windows file shares on Unix guest machines (brandonkelly)
- Bug #16666: Fixed `yii\helpers\ArrayHelper::merge` (rustamwin)

16
framework/db/ActiveQuery.php

@ -172,19 +172,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
/* @var $viaQuery ActiveQuery */
list($viaName, $viaQuery) = $this->via;
if ($viaQuery->multiple) {
if ($this->primaryModel->isRelationPopulated($viaName)) {
$viaModels = $this->primaryModel->$viaName;
} else {
$viaModels = $viaQuery->all();
$this->primaryModel->populateRelation($viaName, $viaModels);
}
$viaModels = $viaQuery->all();
$this->primaryModel->populateRelation($viaName, $viaModels);
} else {
if ($this->primaryModel->isRelationPopulated($viaName)) {
$model = $this->primaryModel->$viaName;
} else {
$model = $viaQuery->one();
$this->primaryModel->populateRelation($viaName, $model);
}
$model = $viaQuery->one();
$this->primaryModel->populateRelation($viaName, $model);
$viaModels = $model === null ? [] : [$model];
}
$this->filterByModels($viaModels);

Loading…
Cancel
Save