Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
338 stars 40 forks source link

Preview stopped working for "content" #172

Closed pozylon closed 1 month ago

pozylon commented 3 months ago
{
  "message": "array_merge(): Argument #1 must be of type array, false given",
  "file": "/var/www/html/modules/Content/Helper/Model.php",
  "line": 103,
  "trace": [
    {
      "file": "/var/www/html/modules/Content/Helper/Model.php",
      "line": 103,
      "function": "array_merge",
      "args": [
        false,
        {
          "preview": [
            {
              "name": "LOCAL",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug=/news/"
            },
            {
              "name": "DEtauk",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug={data.slug}"
            }
          ],
          "name": "news",
          "label": "Aktuelles",
          "info": "",
          "type": "collection",
          "fields": [
            {
              "name": "cover",
              "type": "asset",
              "label": "Cover",
              "info": "So hochauflösend wie möglich",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "title",
              "type": "text",
              "label": "Titel",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "author",
              "type": "text",
              "label": "Autor",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "publicationDate",
              "type": "date",
              "label": "Publikationsdatum",
              "info": "Das Feld wird für die Sortierung und die Datumsanzeige genutzt",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "readonly": false,
                "placeholder": null,
                "min": null,
                "max": null,
                "step": null
              }
            },
            {
              "name": "content",
              "type": "wysiwyg",
              "label": "Inhalt",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "documents",
              "type": "asset",
              "label": "Dokumente",
              "info": "Anhänge (werden auf der rechten Seite angezeigt)",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": true,
              "meta": [],
              "opts": []
            },
            {
              "name": "tags",
              "type": "tags",
              "label": "Tags",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "slug",
              "type": "text",
              "label": "",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null,
                "slugField": "title"
              }
            }
          ],
          "group": "",
          "meta": null,
          "_created": 1701783756,
          "_modified": 1707472635,
          "color": "#831100",
          "revisions": true,
          "icon": "#config:icons/newspaper.svg"
        }
      ]
    },
    {
      "file": "/var/www/html/modules/Content/Helper/Model.php",
      "line": 127,
      "function": "update",
      "class": "Content\\Helper\\Model",
      "type": "->",
      "args": [
        "news",
        {
          "preview": [
            {
              "name": "LOCAL",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug=/news/"
            },
            {
              "name": "DEtauk",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug={data.slug}"
            }
          ],
          "name": "news",
          "label": "Aktuelles",
          "info": "",
          "type": "collection",
          "fields": [
            {
              "name": "cover",
              "type": "asset",
              "label": "Cover",
              "info": "So hochauflösend wie möglich",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "title",
              "type": "text",
              "label": "Titel",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "author",
              "type": "text",
              "label": "Autor",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "publicationDate",
              "type": "date",
              "label": "Publikationsdatum",
              "info": "Das Feld wird für die Sortierung und die Datumsanzeige genutzt",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "readonly": false,
                "placeholder": null,
                "min": null,
                "max": null,
                "step": null
              }
            },
            {
              "name": "content",
              "type": "wysiwyg",
              "label": "Inhalt",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "documents",
              "type": "asset",
              "label": "Dokumente",
              "info": "Anhänge (werden auf der rechten Seite angezeigt)",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": true,
              "meta": [],
              "opts": []
            },
            {
              "name": "tags",
              "type": "tags",
              "label": "Tags",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "slug",
              "type": "text",
              "label": "",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null,
                "slugField": "title"
              }
            }
          ],
          "group": "",
          "meta": null,
          "_created": 1701783756,
          "_modified": 1707472635,
          "color": "#831100",
          "revisions": true,
          "icon": "#config:icons/newspaper.svg"
        }
      ]
    },
    {
      "file": "/var/www/html/modules/Content/bootstrap.php",
      "line": 38,
      "function": "save",
      "class": "Content\\Helper\\Model",
      "type": "->",
      "args": [
        "news",
        {
          "preview": [
            {
              "name": "LOCAL",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug=/news/"
            },
            {
              "name": "DEtauk",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug={data.slug}"
            }
          ],
          "name": "news",
          "label": "Aktuelles",
          "info": "",
          "type": "collection",
          "fields": [
            {
              "name": "cover",
              "type": "asset",
              "label": "Cover",
              "info": "So hochauflösend wie möglich",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "title",
              "type": "text",
              "label": "Titel",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "author",
              "type": "text",
              "label": "Autor",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "publicationDate",
              "type": "date",
              "label": "Publikationsdatum",
              "info": "Das Feld wird für die Sortierung und die Datumsanzeige genutzt",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "readonly": false,
                "placeholder": null,
                "min": null,
                "max": null,
                "step": null
              }
            },
            {
              "name": "content",
              "type": "wysiwyg",
              "label": "Inhalt",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "documents",
              "type": "asset",
              "label": "Dokumente",
              "info": "Anhänge (werden auf der rechten Seite angezeigt)",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": true,
              "meta": [],
              "opts": []
            },
            {
              "name": "tags",
              "type": "tags",
              "label": "Tags",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "slug",
              "type": "text",
              "label": "",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null,
                "slugField": "title"
              }
            }
          ],
          "group": "",
          "meta": null,
          "_created": 1701783756,
          "_modified": 1707472517,
          "color": "#831100",
          "revisions": true,
          "icon": "#config:icons/newspaper.svg"
        }
      ]
    },
    {
      "file": "/var/www/html/lib/Lime/App.php",
      "line": 1363,
      "function": "{closure}",
      "class": "Lime\\Module",
      "type": "->",
      "args": [
        "news",
        {
          "preview": [
            {
              "name": "LOCAL",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug=/news/"
            },
            {
              "name": "DEtauk",
              "uri": "http://localhost:3000/api/draft?secret=secret&slug={data.slug}"
            }
          ],
          "name": "news",
          "label": "Aktuelles",
          "info": "",
          "type": "collection",
          "fields": [
            {
              "name": "cover",
              "type": "asset",
              "label": "Cover",
              "info": "So hochauflösend wie möglich",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "title",
              "type": "text",
              "label": "Titel",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "author",
              "type": "text",
              "label": "Autor",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null
              }
            },
            {
              "name": "publicationDate",
              "type": "date",
              "label": "Publikationsdatum",
              "info": "Das Feld wird für die Sortierung und die Datumsanzeige genutzt",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": {
                "readonly": false,
                "placeholder": null,
                "min": null,
                "max": null,
                "step": null
              }
            },
            {
              "name": "content",
              "type": "wysiwyg",
              "label": "Inhalt",
              "info": "",
              "group": "",
              "i18n": false,
              "required": true,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "documents",
              "type": "asset",
              "label": "Dokumente",
              "info": "Anhänge (werden auf der rechten Seite angezeigt)",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": true,
              "meta": [],
              "opts": []
            },
            {
              "name": "tags",
              "type": "tags",
              "label": "Tags",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": []
            },
            {
              "name": "slug",
              "type": "text",
              "label": "",
              "info": "",
              "group": "",
              "i18n": false,
              "required": false,
              "multiple": false,
              "meta": [],
              "opts": {
                "multiline": false,
                "showCount": true,
                "readonly": false,
                "placeholder": null,
                "minlength": null,
                "maxlength": null,
                "list": null,
                "slugField": "title"
              }
            }
          ],
          "group": "",
          "meta": null,
          "_created": 1701783756,
          "_modified": 1707472517,
          "color": "#831100",
          "revisions": true,
          "icon": "#config:icons/newspaper.svg"
        }
      ]
    }
  ]
}

Seems to be another regression with the newer versions @aheinze but this time I don't know how to fix

Mikearaya commented 3 months ago

additional info: this happens when setting a preview page URL for more than one collection/content

aheinze commented 3 months ago

when does the error occur?

Mikearaya commented 3 months ago

@aheinze when setting a preview URL for a collection. when it's set for only one collection it is fine but if you set the preview endpoint for more than two collections there is a problem

aheinze commented 3 months ago

when you create a new collection or update an existing one?

aheinze commented 3 months ago

Is it possible to create a video, so I can understand when and where the error happens?

Mikearaya commented 3 months ago

update existing one, with a preview url

aheinze commented 3 months ago

nope, can't reproduce

Mikearaya commented 3 months ago

@pozylon and I were able to identify the root cause. it is related to the behavior of array_merge


If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value but will be appended.

basically, if you have multiple preview endpoints for different collections with the same key it will break the code

so while we can work around this issue for now I think it should not be implemented like that. it is not like this on older versions

aheinze commented 3 months ago

basically, if you have multiple preview endpoints for different collections with the same key it will break the code

I still don't get it. Can you provide more details or context?

pozylon commented 3 months ago

basically, if you have multiple preview endpoints for different collections with the same key it will break the code

I still don't get it. Can you provide more details or context?

If i use test-a and test-b as keys it works

aheinze commented 3 months ago

@pozylon Thanks, unfortunately I still can't reproduce it. Do you have any custom code that hooks into the content model save event maybe?

aheinze commented 3 months ago

Let me know if I can support you to investigate the issue, as I want to release a new version soon and want to make sure that this issue won't get shipped with the next version

pozylon commented 3 months ago

Let me know if I can support you to investigate the issue, as I want to release a new version soon and want to make sure that this issue won't get shipped with the next version

We are trying to reproduce the issue locally but without success yet. It's weird because we use the cockpit pro docker image. Trying to spot the difference...