Plugin (hook) exception/error handling

Now that we can use php7 features, another thing that is coming soon is this:

https://git.tt-rss.org/fox/tt-rss/src/branch/wip-hook-callbacks

It’s a rather invasive change (on the tt-rss core side, not for plugins) so expect some hook-related bugs if I screw up somewhere while rewriting all the endless hook runners. if your plugin suddenly gets broken, you know where to post.

  • EDIT: ok just changing my function to function hook_prefs_tabs(...$args) fixes it. Don’t think it was your problem at all. The joy that is old legacy code you’ve never looked at hey?

Looks like I’m now having issues with the pref_tabs hook in feediron. Just did a restart to make sure I’m up-to-date v21.02-3655e7aaf

E_USER_WARNING (512)	classes/pluginhost.php:147	ArgumentCountError: Too few arguments to function Feediron::hook_prefs_tabs(), 0 passed in /var/www/html/tt-rss/classes/pluginhost.php on line 143 and exactly 1 expected in /var/www/html/tt-rss/plugins.local/feediron/init.php:606
Stack trace:
#0 /var/www/html/tt-rss/classes/pluginhost.php(143): Feediron->hook_prefs_tabs()
#1 /var/www/html/tt-rss/prefs.php(163): PluginHost->run_hooks()
#2 {main}
1. classes/pluginhost.php(147): user_error(ArgumentCountError: Too few arguments to function Feediron::hook_prefs_tabs(), 0 passed in /var/www/html/tt-rss/classes/pluginhost.php on line 143 and exactly 1 expected in /var/www/html/tt-rss/plugins.local/feediron/init.php:606
Stack trace:
#0 /var/www/h..., 512)
2. prefs.php(163): run_hooks(hook_prefs_tabs)

How I’m currently hooking in feediron

  // Required API for adding the hooks
  function init($host)
  {
    $this->host = $host;
    $host->add_hook($host::HOOK_PREFS_TABS, $this);
    $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
  }

[...]

  function hook_prefs_tabs($args)
  {
    print '<div id="feedironConfigTab" dojoType="dijit.layout.ContentPane"
    href="backend.php?op=feediron"
    title="' . __('FeedIron') . '"></div>';
  }

i suppose previously all hooks invoked by run_hooks() had to have at least one argument but now it’s different per-hook, which affected some lesser used (i.e. i didn’t have any ready examples for) hooks.

i think this prototype should just be hook_prefs_tabs() because it’s not getting passed anything anyway. the argument previously passed was a dummy, i think.

btw because of stuff like this i’ve noted all hook prototypes in pluginhost, right where the hooks are defined.

Ah that’s embarrassing, I missed the comments because I was looking at it in the browser and it got cut off. Next time I’ll read this stuff directly from a file.

Not sure this error belongs in this thread, however, the following is being thrown every minute or so after latest update:

E_DEPRECATED (8192) nknown:0 Directive ‘track_errors’ is deprecated

third party plugin or something? i don’t think there’s anything like that in tt-rss.

Thanks - I don’t have any third party plugins, however???

track_errors “0” PHP_INI_ALL Deprecated as of PHP 7.2.0.

Perhaps find track_errors in your PHP setup and remove it.

That worked! Thanks!!