pluginhost: deny hook registration to plugins which lack relevant implementation methods

This commit is contained in:
Andrew Dolgov 2021-02-08 19:16:53 +03:00
parent 51d2deeea9
commit a341a838b1
1 changed files with 9 additions and 0 deletions

View File

@ -204,6 +204,15 @@ class PluginHost {
function add_hook($type, $sender, $priority = 50) {
$priority = (int) $priority;
if (!method_exists($sender, strtolower($type))) {
user_error(
sprintf("Plugin %s tried to register a hook without implementation: %s",
get_class($sender), $type),
E_USER_WARNING
);
return;
}
if (empty($this->hooks[$type])) {
$this->hooks[$type] = [];
}