mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8505 from creative-commoners/pulls/4.3/defensive-extensions
FIX getExtensionInstance can return null, add a case to handle that
This commit is contained in:
commit
88d78dfd95
@ -135,6 +135,10 @@ trait Extensible
|
||||
$this->addCallbackMethod($method, function ($inst, $args) use ($method, $extensionClass) {
|
||||
/** @var Extensible $inst */
|
||||
$extension = $inst->getExtensionInstance($extensionClass);
|
||||
if (!$extension) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$extension->setOwner($inst);
|
||||
return call_user_func_array([$extension, $method], $args);
|
||||
|
@ -85,5 +85,6 @@ class ExtensionTestState implements TestState
|
||||
|
||||
public function tearDownOnce($class)
|
||||
{
|
||||
DataObject::flush_extra_methods_cache();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user