Broken panel after update from 3.5 to 3.6

Hey Kirby Forum,

in order to use a newer PHP version I tried updating my site’s Kirby Version. I am aiming to push the Kirby version as high as possible but started from 3.5 to 3.6 and with a change of PHP 7.4 to PHP 8.0. Unfortunately I now get the following error in the panel making it impossible to access my pages:

The section "pages" could not be loaded: array_merge(): Argument #3 must be of type array, string given

This is my site.yml:

title: Site
sections:
  pages:
    image: icon
    label: Seiten
    preset: pages
    unlisted: false

I already did some digging in the release notes to check whether there are any breaking changes but couldn’t find the culprit as my blueprint seems rather basic to me and I don’t make use of page models.

Does anyone have an idea how to fix this?

Try this

If you need the docs for 3.6: Reference | Kirby CMS

Thanks for the reply! That line definitely was an accident waiting to happen but it didn’t solve the main issue unfortunately.

Did you try another name for the section? Maybe “pages” is not allowed (anymore)?

Good idea! I changed the name and noticed that way that the preset attribute seems to be deprecated as well so I changed the yml to the following

title: Site
sections:
  test:
    image: icon
    label: Seiten
    type: pages

which sadly returns the same error as initially :smile:

The name is not the problem, a section can be called pages. I can’t see an issue with this section, actually.

Make sure that your indentation is correct.

I validated the yml indentation and no errors were found.

When I delete the Kirby and vendor folders as well as the cache and media folder and reinstall Kirby 3.5 with PHP 7.4 the error is gone. So I assume it must be related to changes made to Kirby from 3.5 to 3.6. Do I need to update my pages in a certain way? I haven’t dealt with the Kirby core but to me it seems the panel is querying all pages and tries to merge them with array_merge in order to show them. If the error message states that one element is string instead of array could that mean there is JSON representation of a page present that doesn’t get decoded?

Can you find more details in the console, maybe?

And which 3.6 version exactly are you using?

For reference: I renamed the section back to pages.
The console states the following:

GET http://localhost:8000/api/site/sections/pages?page=1 500 (Internal Server Error)

which surfaced at index.js:1

My exact Kirby version is 3.6.6.2 but I also tried 3.6.0, 3.7.0 and 3.8.2.

Is debug set to true in your config?

I’m pretty sure the error is not in this pages definition, but rather somewhere else, maybe in one of the other blueprints or in a template/model.

That’s why it would be important to find out where the error originates. Please also check your server and PHP error logs.

And what does your section definition now look like?

I now set debug to true and got this additional message in the console:

index.js:1 
{status: 'error', message: 'array_merge(): Argument #3 must be of type array, string given', code: 500, exception: 'TypeError', key: null, …}
code: 500
details: 
Array(0)
length: 0
[[Prototype]]: Array(0)
exception: "TypeError"
file: "/kirby/src/Panel/Model.php"
key: null
line: 138
message: "array_merge(): Argument #3 must be of type array, string given"
route: "site/sections/([a-zA-Z0-9\\.\\-_%= \\+\\@\\(\\)]+)"
status: "error"
[[Prototype]]:Object

I am running the site locally with PHP. I checked and by default I don’t have error_logs enabled. I’ll look into enabling them to see if there is more info.

My section is now looking like this:

title: Site
sections:
  pages:
    image: icon
    label: Seiten
    type: pages

Ok, it refers to the third argument here ($this->model->blueprint()->image() ?? [])

  $settings = array_merge(
            $this->imageDefaults(),
            $settings ?? [],
            $this->model->blueprint()->image() ?? [],
        );

Has any of your page blueprints an image option set?

Yes, there is the team-member.yml:

title: Team member
preset: page
icon: user

status:
  draft: true
  listed: true

fields:
  position:
    label: Position
    type: text
  phone:
    label: Phone
    type: tel
    width: 1/2
  email:
    label: Email
    type: email
    width: 1/2
  image:
    extends: sections/image
    headline: Team Member
    min: 1
    max: 1
    image:
      ratio: 1/1
      cover: true

and the extended section is looking like this:

type: files
headline: Bild
max: 1
layout: cards
info: "{{ file.dimensions }}"

I checked if it resolves the error to remove the image option. It did not.

This definitely doesn’t make sense, you are trying to load a section instead of a field here. But if that’s not what is causing the error, maybe there are more templates…

Yes, you are right. I found an initially missed image option in another template that I removed and now everything is working properly. Thanks for the help!