setContent() error

Hi there!

Kirby is giving me the following error whenever I’m on a certain page.
I tried deleting and creating the page again. I also set the blueprint to the default blueprint.
The page is accessible and editable in the panel.

For testing reasons, the template for the page itself does not include any php. Unfortunately, I can’t figure out why it’s throwing that error or what the error means. Google did not help.

Thanks!

Which Kirby version?

What is inside the content text file?

Version 3.0.1

The content file:

Title: Impressum

Oh, that’s an old version. Please check if the error persists if you update to the latest version.

I updated to version 3.1.4 and the error still persists. : /

This is really weird. If I manually rename the folder, the content file, the blueprint and the template to something other than “impressum”, it works.

There’s no other folder or file or reference by the name “impressum”.

I think we should try to narrow it down a bit. What happens if you keep blueprint name , template name and text filename and only rename the folder name?

If the blueprint name, the template name and text filename is “impressum” and the folder name is something like “test” it works. If I change the folder name back to “impressum” it throwing the error again.

Are you using any plugins?

No, no plugins at all.
The problem persists in version 3.2.
Also if the page is only accessible via url – without a number in the folder’s name.

Hm, I have. no idea what’s happening there. Have you deleted the media and session folders after updating and cleared the cache folder and your browser cache?

Yeah, everything.

It’s really weird, because it’s just the folder name “3_impressum” which causes the error. There’re not even any hidden files.

What does the error actually mean “setContent”, TypeError?

It means that the method setContent() expects an array or null as parameter but for some reason, it gets an object instead.

Could you send me your project as zip?

Ah, ok.

Ok, I’m stripping some content and zipping it.
Do I send you the zip via PM?

It’s best to upload it to Dropbox or whatever and send me the link via PM

Ok

Make sure that the stripped down version still has the error :wink:

:smiley:

For anyone coming here with the same error: It was caused by a route with the same pattern as the page slug that returned a new page object with the content set to an object instead of an array.

   [
           'pattern' => 'impressum',
           'action'  => function () {
             return new Page([
               'slug' => 'impressum',
               'template' => 'impressum',
               'content' => page('impressum') // content expects an array, not an object
             ]);
           }
         ],
1 Like

Thanks for checking and finding the culprit!