Generated with the help of an LLM.
Problem/Motivation
When a module or theme that provides a layout is uninstalled, pages with sections that use that layout fail. The edit form and the section type form fail as well, and the page can't be saved.
Section types that use the layout are also deleted along with the module.
Saving fails because core's Section::toArray() needs the layout plugin.
Steps to reproduce
- Install a module that provides a layout.
- Add a "Content builder" field to the "Basic page" content type. New layouts start enabled.
- Create a basic page with a section in that layout, and save it.
- Uninstall the module.
- Edit the page and save it.
Saving the page fails with this error (my_layout is the uninstalled layout):
Drupal\Core\Entity\EntityStorageException: The "my_layout" plugin does not exist. Valid plugin IDs for Drupal\Core\Layout\LayoutPluginManager are: layout_twocol_section, layout_threecol_section, layout_fourcol_section, layout_onecol, layout_twocol, layout_twocol_bricks, layout_threecol_25_50_25, layout_threecol_33_34_33, layout_builder_blank
#0 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(861)
#1 core/lib/Drupal/Core/Entity/EntityBase.php(371)
Caused by Drupal\Component\Plugin\Exception\PluginNotFoundException: The "my_layout" plugin does not exist. Valid plugin IDs for Drupal\Core\Layout\LayoutPluginManager are: layout_twocol_section, layout_threecol_section, layout_fourcol_section, layout_onecol, layout_twocol, layout_twocol_bricks, layout_threecol_25_50_25, layout_threecol_33_34_33, layout_builder_blank
#0 core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php(53)
#1 core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(28)
#2 core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(16)
#3 core/lib/Drupal/Component/Plugin/PluginManagerBase.php(85)
#4 core/modules/layout_builder/src/Section.php(116)
#5 core/modules/layout_builder/src/Section.php(146)
#6 core/modules/layout_builder/src/Section.php(358)
#7 modules/contrib/content_builder/src/Field/ContentBuilderItemList.php(115)
#8 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(1076)Proposed resolution
Show a section that is missing a layout in another layout, available in the following order: the section type's layout, a layout with the same regions that keeps the block columns, or the one column layout as the default fallback. When a layout is missing, show and log a warning on the related section(s) in the edit form, and show a warning on the section type form.
Saving keeps the missing layout and its settings until a user chooses another layout. The section comes back if the missing layout's module does.
Keep section types when a layout's module is uninstalled. The section type form will ask for a new layout.
Remaining tasks
None
User interface changes
The edit form shows a warning on a section whose layout is missing. Section types also show a warning and ask for a new layout when their layout is missing.
API changes
None
Data model changes
None
Comments
Comment #2
gloriaswebtech commentedComment #3
gloriaswebtech commentedComment #4
gloriaswebtech commentedComment #5
gloriaswebtech commentedComment #6
gloriaswebtech commentedComment #8
gloriaswebtech commentedFixed in 1.0.2