pluginhost: deny hook registration to plugins which lack relevant implementation methods
This commit is contained in:
parent
51d2deeea9
commit
a341a838b1
|
@ -204,6 +204,15 @@ class PluginHost {
|
||||||
function add_hook($type, $sender, $priority = 50) {
|
function add_hook($type, $sender, $priority = 50) {
|
||||||
$priority = (int) $priority;
|
$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])) {
|
if (empty($this->hooks[$type])) {
|
||||||
$this->hooks[$type] = [];
|
$this->hooks[$type] = [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue