Fatal error when creating new node with IPE enabled

Created on 15 December 2022, about 2 years ago
Updated 10 April 2023, over 1 year ago

Problem/Motivation

Testing with Layout Builder IPE 1.0.x-dev on a clean instance of Drupal 9.4.8.

When I attempt to create a new node for a content type with Layout Builder IPE enabled, I get a fatal error:

The website encountered an unexpected error. Please try again later.
AssertionError: Cannot load the "node" entity with NULL ID. in assert() (line 295 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
assert(, 'Cannot load the "node" entity with NULL ID.') (Line: 295)
Drupal\Core\Entity\EntityStorageBase->load(NULL) (Line: 1151)
Drupal\Core\Entity\ContentEntityStorageBase->loadUnchanged(NULL) (Line: 175)
layout_builder_ipe_form_alter(Array, Object, 'node_page_form') (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_page_form') (Line: 835)
Drupal\Core\Form\FormBuilder->prepareForm('node_page_form', Array, Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 159)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Install Layout Builder IPE
  2. Visit Administration > Structure> Content types > Basic page > Manage display > Full content
  3. Check the Use Layout Builder, Allow each content item to have its layout customized, and Use the Layout Builder IPE frontend options, and Save settings
  4. Attempt to add a new Basic Page node

Proposed resolution

Line 171 of layout_builder_ipe_form_alter() should check if $entity-->isNew() before using $entity-->id() (which will be null for new entities).

Remaining tasks

  1. Patch
  2. Review
  3. Commit

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024