johnbillion/query-monitor

Fatal error using latest Timber

LoranRendel opened this issue · 3 comments

When using latest version of Timber and starter theme with Query Monitor enabled, an error occurs:

Fatal error: Uncaught Exception: An exception has been thrown during the rendering of a template ("Too few arguments to function QM_Collector_Theme::action_get_position(), 0 passed in example.com\wp-includes\class-wp-hook.php on line 324 and exactly 1 expected").
in example.com\wp-content\themes\copy\views\partials\head.twig on line 7

Thanks for the report! This appears to be a bug in the Timber starter theme. The get_header and get_footer actions must be passed a parameter, even if its value is null. Ref: https://developer.wordpress.org/reference/hooks/get_header/ .

It could be called wrong usage, however, do_action can be called without any additional arguments and no errors: https://developer.wordpress.org/reference/functions/do_action/#source, ...$arg technically could be omitted.

The error occurs only when Query Monitor is active, otherwise evertything works fine.

The get_header and get_footer actions must be passed a parameter, even if its value is null.

That is fascinating.