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:
Dylan K. Taylor 2024-02-19 16:53:53 +00:00
parent 2616d8c5ad
commit 4fab518384
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

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