Inline block loading active block_content revision even if serialized block exists

Created on 12 July 2019, over 5 years ago
Updated 28 October 2024, 27 days 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

Comments & Activities

Not all content is available!

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

  • Can confirm that #10 is still applying and working for us too. As 3 people confirmed that this is working and the patch contains tests, I'm taking the liberty of marking this as RTBC.

  • 🇨🇦Canada gordonio

    I believe I am seeing the same issues as #12, but for the most part it's working fine. It was reproducible when I had more than two languages.

    1. Enable more than 2 languages
    2. Create a page in the original language
    3. Translate to One of the other languages
    4. Translate to the third language

    What I was seeing was:

    1. Original language is always okay
    2. The block description of either of the translated ones would use the text of the previously translated item. For example, set the block translation in french. Then create a spanish version and save the block. The french block description would be the spanish one when viewing, but show the french text when editing.

    It appears to be unrelated to this module and there is a thread for what I believe is the same issue here: https://www.drupal.org/project/drupal/issues/3240993 Let layout builder render inline block translations Needs work

Production build 0.71.5 2024