mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Reset the methods applied to classes after adding/removing extensions. (from r89957) (from r96726)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102348 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4a82105d40
commit
007b309e62
@ -408,6 +408,7 @@ abstract class Object {
|
||||
$subclasses[] = $class;
|
||||
if($subclasses) foreach($subclasses as $subclass) {
|
||||
unset(self::$classes_constructed[$subclass]);
|
||||
unset(self::$extra_methods[$subclass]);
|
||||
}
|
||||
|
||||
// merge with existing static vars
|
||||
@ -476,6 +477,16 @@ abstract class Object {
|
||||
// unset singletons to avoid side-effects
|
||||
global $_SINGLETONS;
|
||||
$_SINGLETONS = array();
|
||||
|
||||
// unset some caches
|
||||
self::$cached_statics[$class]['extensions'] = null;
|
||||
$subclasses = ClassInfo::subclassesFor($class);
|
||||
$subclasses[] = $class;
|
||||
if($subclasses) foreach($subclasses as $subclass) {
|
||||
unset(self::$classes_constructed[$subclass]);
|
||||
unset(self::$extra_methods[$subclass]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,6 +551,12 @@ abstract class Object {
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $arguments) {
|
||||
// If the method cache was cleared by an an Object::add_extension() / Object::remove_extension()
|
||||
// call, then we should rebuild it.
|
||||
if(empty(self::$cached_statics[get_class($this)])) {
|
||||
$this->defineMethods();
|
||||
}
|
||||
|
||||
$method = strtolower($method);
|
||||
|
||||
if(isset(self::$extra_methods[$this->class][$method])) {
|
||||
@ -583,6 +600,7 @@ abstract class Object {
|
||||
}
|
||||
} else {
|
||||
// Please do not change the exception code number below.
|
||||
|
||||
throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user