diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bb2838543..9b4710405a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.38 under development ------------------------ +- Enh #18213: Do not load fixtures with circular dependencies twice instead of throwing an exception (JesseHines0) - Bug #18066: Fixed `yii\db\Query::create()` wasn't using all info from `withQuery()` (maximkou) - Bug #18269: Fix integer safe attribute to work properly in `yii\base\Model` (Ladone) - Enh #18236: Allow `yii\filters\RateLimiter` to accept a closure function for the `$user` property in order to assign values on runtime (nadar) diff --git a/test/FixtureTrait.php b/test/FixtureTrait.php index 49ca57fa80..e5dc9b09a3 100644 --- a/test/FixtureTrait.php +++ b/test/FixtureTrait.php @@ -165,12 +165,11 @@ public function getFixture($name) /** * Creates the specified fixture instances. - * All dependent fixtures will also be created. + * All dependent fixtures will also be created. Duplicate fixtures and circular dependencies will only be created once. * @param array $fixtures the fixtures to be created. You may provide fixture names or fixture configurations. * If this parameter is not provided, the fixtures specified in [[globalFixtures()]] and [[fixtures()]] will be created. * @return Fixture[] the created fixture instances - * @throws InvalidConfigException if fixtures are not properly configured or if a circular dependency among - * the fixtures is detected. + * @throws InvalidConfigException if fixtures are not properly configured */ protected function createFixtures(array $fixtures) { @@ -210,9 +209,8 @@ protected function createFixtures(array $fixtures) // need to use the configuration provided in test case $stack[] = isset($config[$dep]) ? $config[$dep] : ['class' => $dep]; } - } elseif ($instances[$name] === false) { - throw new InvalidConfigException("A circular dependency is detected for fixture '$class'."); } + // if the fixture is already loaded (ie. a circular dependency or if two fixtures depend on the same fixture) just skip it. } }