From 61e06bc57eff73287c66b739a4fdc93357cf7979 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 3 Feb 2010 07:12:15 +0000 Subject: [PATCH] MINOR Allow creating fixture records without any columns by checking the fields exist first before doing a foreach() in YamlFixture::writeDataObject() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98055 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/YamlFixture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/model/YamlFixture.php b/core/model/YamlFixture.php index 768b0d300..82a796eae 100644 --- a/core/model/YamlFixture.php +++ b/core/model/YamlFixture.php @@ -179,7 +179,7 @@ class YamlFixture extends Object { } // Populate the dictionary with the ID - foreach($fields as $fieldName => $fieldVal) { + if($fields) foreach($fields as $fieldName => $fieldVal) { if($obj->many_many($fieldName) || $obj->has_many($fieldName) || $obj->has_one($fieldName)) continue; $obj->$fieldName = $this->parseFixtureVal($fieldVal); } @@ -189,7 +189,7 @@ class YamlFixture extends Object { $this->fixtureDictionary[$dataClass][$identifier] = $obj->ID; // Populate all relations - foreach($fields as $fieldName => $fieldVal) { + if($fields) foreach($fields as $fieldName => $fieldVal) { if($obj->many_many($fieldName) || $obj->has_many($fieldName)) { $parsedItems = array(); $items = preg_split('/ *, */',trim($fieldVal));