Inline block loading active block_content revision even if serialized block exists

Created on 12 July 2019, about 6 years ago
Updated 28 October 2024, 11 months ago

Problem/Motivation

The inline block form is always loading the active block_content entity from the entity repository as long as it is not a new inline block or block_content. This is causing an issue in the following situation:
1) Create and save a node of a content type that allows layout builder overrides
2) Edit the layout to create the override, and add an inline block to any section.
3) Add block field data as desired and save the layout.
4) Go back to edit the layout.
5) Click to configure the existing inline block. Change field data to different values and update the block. Do not save the layout.
6) Click to configure the block again and notice that the block fields have stale data.

Proposed resolution

Issue seems to be in this code:

if (!$this->isNew && !$block->isNew()) {
      // Get the active block for editing purposes.
      $block = \Drupal::service('entity.repository')->getActive('block_content', $block->id());
    }

Checking whether inline block configuration contains serialized block data before loading the active entity from the entity repository should address it.

Remaining tasks

Needs tests.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

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

Merge Requests

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