From 63ce7ea705fbe47930d1d3a2792d0c7d09a0a109 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 14 Nov 2019 07:01:45 +0300 Subject: [PATCH] add a plugin page warning for plugins using HOOK_FEED_FETCHED, etc --- classes/pref/prefs.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 8d9790de2..e66052657 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -844,6 +844,24 @@ class Pref_Prefs extends Handler_Protected { print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); } + $feed_handler_whitelist = [ "Af_Comics" ]; + + $feed_handlers = array_merge( + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); + + $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { + return in_array(get_class($plugin), $feed_handler_whitelist) === FALSE; }); + + if (count($feed_handlers) > 0) { + print_error( + T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , + implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) + ) . " (".__("More info...").")" + ); + } + print "

".__("System plugins")."

"; print_notice("System plugins are enabled in config.php for all users.");