Error when using require within config.php

I am getting the weirdest of errors and can’t figure it out. When changing page status in the Panel from draft to listed, I receive the error:

Argument 1 passed to Kirby\Cms\App::extendHooks() must be of the type array, boolean given, called in /home/sg/myproject/kirby/src/Cms/AppPlugins.php on line 102

Issue occurs both in production and on my local Valet Linux system.

Now, after quite some detective work (and with pointers from a recent issue), I narrowed it down to the routes/hooks setup in my config. I have included them as follows in config.php:

<?php
return [
	'routes' => require_once 'routes.php',
	'hooks' => require_once 'hooks.php',

Each of these files returns an array, e.g.

<?php
	return [
		[
			'pattern' => 'en/(:all)',

What is interesting is that the error disappears as soon as I move the routes and hooks into the config.php itself.

'routes' => [
	[
		'pattern' => 'en/(:all)',

etc. works just fine. So the problem is “fixed” now (by moving the rules into my main config.php, which in consequence looks rather cluttered) but I wonder what is the problem here? Am I missing something? And, as far as I can tell, this only occured since I recently updated to 3.4, since this setup has been working fine for over a year. Are there any new requirements for includes in config.php that require a change?

Scratching my head,
// Sebastian

getkirby.com config: 'routes' => require __DIR__ . '/routes.php',

1 Like

Oh my! Thank you :pray: