diff --git a/core/Object.php b/core/Object.php index e914bed0d..de263ccb2 100755 --- a/core/Object.php +++ b/core/Object.php @@ -439,7 +439,7 @@ abstract class Object { // load statics now for DataObject classes if(ClassInfo::is_subclass_of($class, 'DataObject')) { - DataObjectDecorator::load_extra_statics($class, $extensionClass); + DataObjectDecorator::load_extra_statics($class, $extension); } } @@ -456,10 +456,7 @@ abstract class Object { if(is_subclass_of($class, 'DataObject')) { $extensions = Object::uninherited_static($class, 'extensions'); if($extensions) foreach($extensions as $extension) { - if(preg_match('/^([^(]*)/', $extension, $matches)) { - $extensionClass = $matches[1]; - DataObjectDecorator::load_extra_statics($class, $extensionClass); - } + DataObjectDecorator::load_extra_statics($class, $extension); } } } diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 3547896ba..c0a0f5796 100755 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -462,7 +462,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $class = get_class($instance); user_error("DataObject::defineMethods(): Please ensure {$class}::__construct() calls parent::__construct()", E_USER_ERROR); } - DataObjectDecorator::load_extra_statics($this->class, $instance->class); } // Set up accessors for joined items diff --git a/core/model/DataObjectDecorator.php b/core/model/DataObjectDecorator.php index 058418b1b..fde4deba3 100755 --- a/core/model/DataObjectDecorator.php +++ b/core/model/DataObjectDecorator.php @@ -48,8 +48,15 @@ abstract class DataObjectDecorator extends Extension { if(!empty(self::$extra_statics_loaded[$class][$extension])) return; self::$extra_statics_loaded[$class][$extension] = true; + if(preg_match('/^([^(]*)/', $extension, $matches)) { + $extensionClass = $matches[1]; + } else { + user_error("Bad extenion '$extension' - can't find classname", E_USER_WARNING); + return; + } + // @deprecated 2.4 - use extraStatics() now, not extraDBFields() - if(method_exists($extension, 'extraDBFields')) { + if(method_exists($extensionClass, 'extraDBFields')) { user_error('DataObjectDecorator::extraDBFields() is deprecated. Please use extraStatics() instead.', E_USER_NOTICE); $extraStaticsMethod = 'extraDBFields'; } else { @@ -57,9 +64,9 @@ abstract class DataObjectDecorator extends Extension { } // If the extension has been manually applied to a subclass, we should ignore that. - if(Object::has_extension(get_parent_class($class), $extension)) return; + if(Object::has_extension(get_parent_class($class), $extensionClass)) return; - $statics = call_user_func(array($extension, $extraStaticsMethod), $class); + $statics = call_user_func(array($extensionClass, $extraStaticsMethod), $class, $extension); if($statics) { foreach($statics as $name => $newVal) {