diff --git a/ORM/DataObject.php b/ORM/DataObject.php index 1cbe4b803..3f70bf169 100644 --- a/ORM/DataObject.php +++ b/ORM/DataObject.php @@ -2954,24 +2954,27 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return DBField The field as a DBField object */ public function dbObject($fieldName) { + // Check for field in DB + $helper = $this->db($fieldName, true); + + if(!$helper) { + return null; + } + $value = isset($this->record[$fieldName]) ? $this->record[$fieldName] : null; // If we have a DBField object in $this->record, then return that - if(is_object($value)) { + if($value instanceof DBField) { return $value; } - // Build and populate new field otherwise - $helper = $this->db($fieldName, true); - if($helper) { - list($table, $spec) = explode('.', $helper); - $obj = Object::create_from_string($spec, $fieldName); - $obj->setTable($table); - $obj->setValue($value, $this, false); - return $obj; - } + list($table, $spec) = explode('.', $helper); + $obj = Object::create_from_string($spec, $fieldName); + $obj->setTable($table); + $obj->setValue($value, $this, false); + return $obj; } /** diff --git a/ORM/Versioning/DataDifferencer.php b/ORM/Versioning/DataDifferencer.php index 43f42f0f8..808d0b9f1 100644 --- a/ORM/Versioning/DataDifferencer.php +++ b/ORM/Versioning/DataDifferencer.php @@ -75,6 +75,8 @@ class DataDifferencer extends ViewableData { public function ignoreFields($ignoredFields) { if(!is_array($ignoredFields)) $ignoredFields = func_get_args(); $this->ignoredFields = array_merge($this->ignoredFields, $ignoredFields); + + return $this; } /**