ENHANCEMENT: Added better error message if defaults are a bad format.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79382 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-06-17 02:13:02 +00:00
parent 5affa62e6c
commit 546a5b2c89

View File

@ -800,6 +800,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
foreach($classes as $class) {
$defaults = Object::get_static($class, 'defaults');
if($defaults && !is_array($defaults)) {
user_error("Bad '$this->class' defaults given: " . var_export($defaults, true),
E_USER_WARNING);
$defaults = null;
}
if($defaults) foreach($defaults as $fieldName => $fieldValue) {
// SRM 2007-03-06: Stricter check
if(!isset($this->$fieldName) || $this->$fieldName === null) {