From a341a838b17605d2f8b5d2eb25a5a7ca496272bc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 8 Feb 2021 19:16:53 +0300 Subject: [PATCH] pluginhost: deny hook registration to plugins which lack relevant implementation methods --- classes/pluginhost.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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] = []; }