mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
PluginManager: do not accept generator functions as event handlers
closes #4912 I didn't merge the original PR because this needs to be checked for explicitly registered handlers as well as auto-detected ones from listeners.
This commit is contained in:
parent
2616d8c5ad
commit
4fab518384
@ -650,6 +650,11 @@ class PluginManager{
|
||||
|
||||
$handlerName = Utils::getNiceClosureName($handler);
|
||||
|
||||
$reflect = new \ReflectionFunction($handler);
|
||||
if($reflect->isGenerator()){
|
||||
throw new PluginException("Generator function $handlerName cannot be used as an event handler");
|
||||
}
|
||||
|
||||
if(!$plugin->isEnabled()){
|
||||
throw new PluginException("Plugin attempted to register event handler " . $handlerName . "() to event " . $event . " while not enabled");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user