Skip to content

Commit

Permalink
Fix #18213: Do not load fixtures with circular dependencies twice ins…
Browse files Browse the repository at this point in the history
…tead of throwing an exception
  • Loading branch information
jesse-r-s-hines authored Sep 7, 2020
1 parent b7168b1 commit 6342ad8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions test/FixtureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
}
}

Expand Down

0 comments on commit 6342ad8

Please sign in to comment.