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:
Daniel Hensby 2018-10-20 16:58:55 +01:00 committed by GitHub
commit 88d78dfd95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -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);

View File

@ -85,5 +85,6 @@ class ExtensionTestState implements TestState
public function tearDownOnce($class)
{
DataObject::flush_extra_methods_cache();
}
}