From 11d6f3c0b0679209fe6674a70c8a85f54373deb4 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 4 Jun 2009 06:20:32 +0000 Subject: [PATCH] Merged from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78410 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- api/XMLDataFormatter.php | 18 +++++++++++------- core/model/DataObject.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/XMLDataFormatter.php b/api/XMLDataFormatter.php index bca69cfba..e7329d6d3 100644 --- a/api/XMLDataFormatter.php +++ b/api/XMLDataFormatter.php @@ -83,10 +83,12 @@ class XMLDataFormatter extends DataFormatter { $xml .= "<$relName linktype=\"has_many\" href=\"$objHref/$relName.xml\">\n"; $items = $obj->$relName(); - foreach($items as $item) { - //$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName/$item->ID"); - $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); - $xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\">\n"; + if ($items) { + foreach($items as $item) { + //$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName/$item->ID"); + $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); + $xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\">\n"; + } } $xml .= "\n"; } @@ -100,9 +102,11 @@ class XMLDataFormatter extends DataFormatter { $xml .= "<$relName linktype=\"many_many\" href=\"$objHref/$relName.xml\">\n"; $items = $obj->$relName(); - foreach($items as $item) { - $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); - $xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\">\n"; + if ($items) { + foreach($items as $item) { + $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); + $xml .= "<$relClass href=\"$href.xml\" id=\"{$item->ID}\">\n"; + } } $xml .= "\n"; } diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 45391f77f..8a16f6392 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -1943,7 +1943,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // At the very least, the type has changed $this->changed[$fieldName] = 1; - if(!isset($this->record[$fieldName]) || $this->record[$fieldName] != $val) { + if((!isset($this->record[$fieldName]) && $val) || (isset($this->record[$fieldName]) && $this->record[$fieldName] != $val)) { // Value has changed as well, not just the type $this->changed[$fieldName] = 2; }