mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-15 22:16:32 +02:00
BUGFIX: Reset the methods applied to classes after adding/removing extensions. (from r89957)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96726 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
658439b804
commit
3419d87476
@ -408,6 +408,7 @@ abstract class Object {
|
|||||||
$subclasses[] = $class;
|
$subclasses[] = $class;
|
||||||
if($subclasses) foreach($subclasses as $subclass) {
|
if($subclasses) foreach($subclasses as $subclass) {
|
||||||
unset(self::$classes_constructed[$subclass]);
|
unset(self::$classes_constructed[$subclass]);
|
||||||
|
unset(self::$extra_methods[$subclass]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge with existing static vars
|
// merge with existing static vars
|
||||||
@ -476,6 +477,16 @@ abstract class Object {
|
|||||||
// unset singletons to avoid side-effects
|
// unset singletons to avoid side-effects
|
||||||
global $_SINGLETONS;
|
global $_SINGLETONS;
|
||||||
$_SINGLETONS = array();
|
$_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
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __call($method, $arguments) {
|
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);
|
$method = strtolower($method);
|
||||||
|
|
||||||
if(isset(self::$extra_methods[$this->class][$method])) {
|
if(isset(self::$extra_methods[$this->class][$method])) {
|
||||||
@ -583,6 +600,7 @@ abstract class Object {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Please do not change the exception code number below.
|
// Please do not change the exception code number below.
|
||||||
|
|
||||||
throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
|
throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user