Receiving null instances in kirby-hook

Kirby version: 3.4.4

I came across an interesting issue with the Kirby hooks, which is that it can be called with null values?
The cases I got currently are the page.update:before and page.update:after hook, both of which are called with a null value for both the newPage and the oldPage argument.

So what does the null value mean? And how do I fix this (since I want to use both references in the hook itself).

Ps. I have been changing the template/blueprint between changing the page content’s, if that should make a difference (not sure how I would otherwise force an file-write tbh). I tried with a fresh page, still the same problem

Could you elaborate a bit more when this happens? Please also post your code?

This happens when I try to save a page from the panel. The page already exist, and when I use the ‘after’ version of the hook. All changes are saved correctly, but it will crash when I try to use either function-parameter because those are null.

App::plugin('my/plugin', [
    'hooks' => [
        'site.update:after' => function ($newSite, $oldSite) {
        'page.create:after' => function ($page) {
        'page.duplicate:after' => function ($new, $original) {
        // 'page.update:before' => function ($new, $old) { < this one yields the same result
        'page.update:after' => function ($new, $old) {
                    // At this point, both $new and $old are `null` for some reason.
        'page.delete:after' => function ($status, $page) {

You have to use the correct named parameter names as in the documentation, for the page.update:after hook that would be$oldPage and $newPage,not $new and $old.

This change was introduced in KIrby 3.4.0

That would have been usefull information before the long search. Should be a good addition to the documentation/specifications.

Thanks for the hint

This is actually in the hooks documentation.