Cockpit icon indicating copy to clipboard operation
Cockpit copied to clipboard

Preview stopped working for "content"

Open pozylon opened this issue 1 year ago • 13 comments

{
  "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

pozylon avatar Feb 09 '24 13:02 pozylon

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

Mikearaya avatar Feb 09 '24 13:02 Mikearaya

when does the error occur?

aheinze avatar Feb 09 '24 13:02 aheinze

@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

Mikearaya avatar Feb 09 '24 13:02 Mikearaya

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

aheinze avatar Feb 09 '24 13:02 aheinze

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

aheinze avatar Feb 09 '24 14:02 aheinze

update existing one, with a preview url

Mikearaya avatar Feb 09 '24 14:02 Mikearaya

nope, can't reproduce

aheinze avatar Feb 09 '24 14:02 aheinze

@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

Mikearaya avatar Feb 09 '24 15:02 Mikearaya

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?

aheinze avatar Feb 09 '24 15:02 aheinze

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?

  • I set the preview endpoint for collection a and name it "test" with some url
  • I set the preview endpoint for collection b and name it "test" with same url as above
  • I go to content overview page, hard refresh -> collections don't show up anymore (only way to fix is manually editing the collection content php files)

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

pozylon avatar Feb 09 '24 15:02 pozylon

@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 avatar Feb 09 '24 16:02 aheinze

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

aheinze avatar Feb 09 '24 21:02 aheinze

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...

pozylon avatar Feb 12 '24 06:02 pozylon