BUGFIX: Fixed array_key_exists check in DataObject->setField that was failing when DataObject->record was not yet initialised by DataObject->setField.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63813 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-10-08 02:25:26 +00:00
parent 431afe234f
commit 9f0718f6df

View File

@ -1732,13 +1732,13 @@ class DataObject extends ViewableData implements DataObjectInterface {
} else {
$defaults = $this->stat('defaults');
// if a field is not existing or has strictly changed
if(!array_key_exists($fieldName, $this->record) || $this->record[$fieldName] !== $val) {
if(!isset($this->record[$fieldName]) || $this->record[$fieldName] !== $val) {
// TODO Add check for php-level defaults which are not set in the db
// TODO Add check for hidden input-fields (readonly) which are not set in the db
// At the very least, the type has changed
$this->changed[$fieldName] = 1;
if(!array_key_exists($fieldName, $this->record) || $this->record[$fieldName] != $val) {
if(!isset($this->record[$fieldName]) || $this->record[$fieldName] != $val) {
// Value has changed as well, not just the type
$this->changed[$fieldName] = 2;
}