concretecms: Bug: pressing "Save Layout as Preset" breaks website if layout is a theme preset

My theme defines a layout preset through function PageTheme::getThemeAreaLayoutPresets. These layouts become available to users to insert into their pages. In all pages any layout can also be saved as a User Preset, using the menu option “Save Layout As Preset” (screenshot).

The problem occurs when the saved layout was originally a theme layout preset. Then pages will no longer load and either time out or run out of memory. When debugging a recursive loop is started through the getPresets functionality.

reproduce

  1. If none exist, add a preset to the current theme (a)
  2. Add a Layout to any page, make sure to select a theme preset (from 1.)
  3. Right click the label of any column in the new layout, and click “Save Layout as Preset” (screenshot)
  4. Give the preset any name and save it.
  5. Publish (or reload) the page; the page doesn’t load anymore

(a) add to page_theme.php

public function getThemeAreaLayoutPresets()
{
    return [
        [
            'handle' => 'example_layout',
            'name' => 'Example layout',
            'container' => '<div class="example-layout"></div>',
            'columns' => ['<div class="example-layout__column"></div>'],
        ],
    ];
}

(screenshot) image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (15 by maintainers)

Most upvoted comments

I can confirm that the fix is working!