backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 38 forks source link

Importing a layout page causes "missing callback" error and "Undefined array key" warning #6639

Open argiepiano opened 3 weeks ago

argiepiano commented 3 weeks ago

Description of the bug

Importing a custom layout page created on a different site causes "missing callback" error and an "Undefined array key..." Warning.

The imported page layout actually shows up under "Layout overrides" instead of "Layout Pages"

Screen Shot 2024-07-01 at 6 54 03 PM Screen Shot 2024-07-01 at 6 55 01 PM

Steps To Reproduce

To reproduce the behavior:

  1. Create a layout page in Site A
  2. In the dropbutton for "manage layout" select "export layout"
  3. Copy the json code
  4. Paste in in Site B's Configuration Manager > Single Import and save
  5. Visit the Structure > Layouts UI and see the problem

Actual behavior

Layout page is imported as a non-functional Layout override, a "missing callback" error is shown, and a warning is shown.

Expected behavior

The Layout page would be imported and it would work as expected.

Additional information

I believe the issue here is that a Layout Page has TWO config files; one is the layout, and the other the layout menu item. For my example pasted above, these are:

So, you need to export/import BOTH files to Site B in order for the imported layout to actually work. The problem happens when you are unaware of this, and you only import the layout json. I assume most users will trust that the "Export layout" link in the dropbutton will give them a "working version" that can be imported in another site, but that's not the case. That only gives you one of the json files.

I really can't think what a good solution might be. I guess we could automatically generate the menu item json upon import (but this will create problems if the person has customized that menu item), or at least throw a warning explaining what's going on.

klonos commented 3 weeks ago

In order to address this properly, we need config dependencies, which is not currently a thing in Backdrop. We basically need #4188.