summaryrefslogtreecommitdiff
path: root/classes/pluginhost.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-08 19:16:53 +0300
committerAndrew Dolgov <[email protected]>2021-02-08 19:16:53 +0300
commita341a838b17605d2f8b5d2eb25a5a7ca496272bc (patch)
treef24f18db539a22293d0dcb69471a48b46172fdce /classes/pluginhost.php
parent51d2deeea911e84ea2e56b78544445de22f881b9 (diff)
pluginhost: deny hook registration to plugins which lack relevant implementation methods
Diffstat (limited to 'classes/pluginhost.php')
-rwxr-xr-xclasses/pluginhost.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 673053b9e..af3cfcc9b 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -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] = [];
}