johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.58k stars 207 forks source link

Fatal error using latest Timber #871

Closed LoranRendel closed 2 months ago

LoranRendel commented 2 months ago

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
johnbillion commented 2 months ago

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/ .

LoranRendel commented 2 months ago

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.

crstauf commented 2 months ago

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

That is fascinating.