From 0a2dcacbcf01e1ebb225570fb99811c4215c6ea9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Nov 2021 11:11:49 +0300 Subject: [PATCH] normalize some mismatching hook function definitions to match base Plugin class --- classes/auth/base.php | 4 ++-- classes/iauthmodule.php | 10 ++++++---- classes/plugin.php | 27 +++++++++++++++++++++------ plugins/af_youtube_embed/init.php | 2 +- plugins/auth_remote/init.php | 2 +- plugins/cache_starred_images/init.php | 2 +- plugins/no_iframes/init.php | 2 +- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/classes/auth/base.php b/classes/auth/base.php index 939a9d358..9950cbf07 100644 --- a/classes/auth/base.php +++ b/classes/auth/base.php @@ -8,8 +8,8 @@ abstract class Auth_Base extends Plugin implements IAuthModule { $this->pdo = Db::pdo(); } - function hook_auth_user(...$args) { - return $this->authenticate(...$args); + function hook_auth_user($login, $password, $service = '') { + return $this->authenticate($login, $password, $service); } // Auto-creates specified user if allowed by system configuration diff --git a/classes/iauthmodule.php b/classes/iauthmodule.php index 39aae4cc2..dbf8c5587 100644 --- a/classes/iauthmodule.php +++ b/classes/iauthmodule.php @@ -3,14 +3,16 @@ interface IAuthModule { /** * @param string $login * @param string $password - * optional third string $service + * @param string $service * @return int|false user_id */ - function authenticate($login, $password); // + optional third parameter: $service + function authenticate($login, $password, $service = ''); /** this is a pluginhost compatibility wrapper that invokes $this->authenticate(...$args) (Auth_Base) - * @param mixed $args = ($login, $password, $service) + * @param string $login + * @param string $password + * @param string $service * @return int|false user_id */ - function hook_auth_user(...$args); + function hook_auth_user($login, $password, $service = ''); } diff --git a/classes/plugin.php b/classes/plugin.php index bcd8c0de7..8c14cd78d 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -1,4 +1,11 @@ authenticate(...$args) (Auth_Base) - * @param mixed $args = ($login, $password, $service) + * @param string $login + * @param string $password + * @param string $service * @return int|false user_id */ - function hook_auth_user(...$args) { + function hook_auth_user($login, $password, $service = '') { user_error("Dummy method invoked.", E_USER_ERROR); return false; } @@ -153,10 +162,10 @@ abstract class Plugin { /** IAuthModule only * @param string $login * @param string $password - * optional third string $service + * @param string $service * @return int|false user_id */ - function authenticate($login, $password) { + function authenticate($login, $password, $service = '') { user_error("Dummy method invoked.", E_USER_ERROR); return false; } @@ -257,6 +266,12 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } + /** + * @param array $entry + * @param int $id + * @param array{'formatted': string, 'entries': array>} $rv + * @return array + */ function hook_enclosure_entry($entry, $id, $rv) { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -289,7 +304,7 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } - function hook_article_image($enclosures, $content, $site_url) { + function hook_article_image($enclosures, $content, $site_url, $article) { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -317,7 +332,7 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } - function hook_pre_subscribe($url, $auth_login, $auth_pass) { + function hook_pre_subscribe(&$url, $auth_login, $auth_pass) { user_error("Dummy method invoked.", E_USER_ERROR); } } diff --git a/plugins/af_youtube_embed/init.php b/plugins/af_youtube_embed/init.php index 771ee8c46..a1be5562a 100644 --- a/plugins/af_youtube_embed/init.php +++ b/plugins/af_youtube_embed/init.php @@ -18,7 +18,7 @@ class Af_Youtube_Embed extends Plugin { "youtu.be"]); } - function hook_render_enclosure($entry, $hide_images) { + function hook_render_enclosure($entry, $id, $rv) { $url = $entry["content_url"]; diff --git a/plugins/auth_remote/init.php b/plugins/auth_remote/init.php index b240a9402..35ee9e31d 100644 --- a/plugins/auth_remote/init.php +++ b/plugins/auth_remote/init.php @@ -29,7 +29,7 @@ class Auth_Remote extends Auth_Base { return ""; } - function authenticate($login, $password) { + function authenticate($login, $password, $service = '') { $try_login = ""; foreach (["REMOTE_USER", "HTTP_REMOTE_USER", "REDIRECT_REMOTE_USER", "PHP_AUTH_USER"] as $hdr) { diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index d94e60504..36e8b73f0 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -97,7 +97,7 @@ class Cache_Starred_Images extends Plugin { } } - function hook_enclosure_entry($enc, $article_id) { + function hook_enclosure_entry($enc, $article_id, $rv) { $local_filename = $article_id . "-" . sha1($enc["content_url"]); if ($this->cache->exists($local_filename)) { diff --git a/plugins/no_iframes/init.php b/plugins/no_iframes/init.php index 3cfa15915..dc297b60e 100644 --- a/plugins/no_iframes/init.php +++ b/plugins/no_iframes/init.php @@ -11,7 +11,7 @@ class No_Iframes extends Plugin { $host->add_hook($host::HOOK_SANITIZE, $this); } - function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) { + function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { $xpath = new DOMXpath($doc); $entries = $xpath->query('//iframe');