BUGFIX: Fixed bug with ID-less generation of YamlFixture entries that trigger $this->write() in setters

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65123 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-03 01:28:18 +00:00
parent 8fb4ea1eaa
commit c573d51d4c

View File

@ -134,13 +134,21 @@ class YamlFixture extends Object {
foreach($fixtureContent as $dataClass => $items) {
foreach($items as $identifier => $fields) {
$obj = new $dataClass();
// If an ID is explicitly passed, then we'll sort out the initial write straight away
// This is just in case field setters triggered by the population code in the next block
// Call $this->write(). (For example, in FileTest)
if(isset($fields['ID'])) {
$obj->ID = $fields['ID'];
$obj->write(false, true);
}
// Populate the dictionary with the ID
foreach($fields as $fieldName => $fieldVal) {
if($obj->many_many($fieldName) || $obj->has_many($fieldName) || $obj->has_one($fieldName)) continue;
$obj->$fieldName = $this->parseFixtureVal($fieldVal);
}
$obj->write(false, true);
$obj->write();
// has to happen before relations in case a class is referring to itself
$this->fixtureDictionary[$dataClass][$identifier] = $obj->ID;