BUGFIX Writing record from yml before parsing relations in YamlFixture->saveIntoDatabase() to avoid missing lookups for reflexive relations on the same object

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64004 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-09 15:07:34 +00:00
parent 06d78ee993
commit 320c30ba5d

View File

@ -130,6 +130,12 @@ class YamlFixture extends Object {
foreach($fixtureContent as $dataClass => $items) {
foreach($items as $identifier => $fields) {
$obj = new $dataClass();
$obj->write();
// Populate the dictionary with the ID
// has to happen before relations in case a class is referring to itself
$this->fixtureDictionary[$dataClass][$identifier] = $obj->ID;
foreach($fields as $fieldName => $fieldVal) {
if($obj->many_many($fieldName) || $obj->has_many($fieldName)) {
$parsedItems = array();
@ -150,9 +156,6 @@ class YamlFixture extends Object {
}
}
$obj->write();
// Populate the dictionary with the ID
$this->fixtureDictionary[$dataClass][$identifier] = $obj->ID;
}
}
}