diff --git a/web/includes/Object.php b/web/includes/Object.php index 1c17ce312..9f29aed88 100644 --- a/web/includes/Object.php +++ b/web/includes/Object.php @@ -110,8 +110,9 @@ class ZM_Object { public static function _find_one($class, $parameters = array(), $options = array() ) { global $object_cache; - if ( ! isset($object_cache[$class]) ) + if ( ! isset($object_cache[$class]) ) { $object_cache[$class] = array(); + } $cache = &$object_cache[$class]; if ( ( count($parameters) == 1 ) and @@ -290,6 +291,16 @@ Logger::Debug("$k => Have default for $v: "); $this->set($new_values); } + foreach ( $this->defaults as $field => $default ) { + if ( (!array_key_exists($field, $this)) or empty($this->{$field}) ) { + if ( is_array($default) ) { + $this->{$field} = $default['default']; + } else { + $this->{$field} = $default; + } + } + } + $fields = array_filter( $this->defaults, function($v) {