kirby-template-hooks icon indicating copy to clipboard operation
kirby-template-hooks copied to clipboard

TypeError when updating a file

Open thomasjonas opened this issue 2 years ago • 1 comments

Whenever I update a file I get this error:

Exception: TypeError Kirby\Cms\App::{closure}(): Argument #2 ($input) must be of type array, null given

So apparently Kirby doesn't always send input. Also the plugin does not use the $input argument, so I think it's best to make it optional. I'll submit a PR in a second.

thomasjonas avatar Aug 10 '23 18:08 thomasjonas

I had the same problem and the fix for me was renaming the $input argument to $values, like in the doc (https://getkirby.com/docs/reference/plugins/hooks/file-update-before)

Apparently you have to use the correct names for arguments. I found it via this post in the forum: https://forum.getkirby.com/t/receiving-null-instances-in-kirby-hook/20352/4

maxesnee avatar Sep 01 '25 16:09 maxesnee