mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +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:
@ -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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user