New revision is not created via Layout Builder

Created on 4 January 2021, almost 4 years ago
Updated 28 July 2023, over 1 year ago

Here's source issue in Paragraph module #3190523: Paragraph is not cloned in Layout builder

Problem/Motivation

For example, if we have created custom block type with one field of Paragraph type and add it to the Page content type via Layout builder, all nodes of Page content type that overwrite layout will initially have reference to the same target_revision_id

When Layout builder is first time saved for a node, for each block following function has been run
$block->createDuplicate()
This will create duplicate of the block, but with the same reference for all referenced fields (this is ok behavior because of Revert to defaults functionality of Layout builder)

Issue is when in this initial layout builder save process, content editor change text of the paragraph. In this step, paragraph still reference to the same target as content type and Entity Reference Revisions (ERR) module doesn't consider this as new revision creation process, and that's why doesn't create a new revision of paragraph.

After Layout has been first time saved for the node, everything works ok. ERR module consider this as new revision and also create a new revision for the paragraph.

Steps to reproduce

  1. first, you need to enable Use Layout builder option for a content type (let's use Basic page for this purpose) and Allow each content item to have its layout customized option
  2. create a new Paragraph type with one plan text field
  3. create a new Block type with field of paragraph type
  4. open Layout builder for the Basic page content type and add inline block for newly created block type
  5. create a new node of type Basic page
  6. open Layout builder for the node, change the text in the block and Save layout

After these steps, if you open Layout builder for the Basic page content type, you can see that text has also been changed in content type.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇷🇸Serbia sakiland

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.

  • 🇷🇸Serbia sakiland

    I've tested this patch for Drupal 9.5, with Drupal core patch #57 from the issue and everything works ok.
    Still I haven't tested this for the Drupal 10.1, but I hope I will have time in the following month to do this too.

  • 🇬🇧United Kingdom longwave UK

    I have a similar issue, but I'm not using Paragraphs. I have a block content entity that has an Entity Reference Revisions field to another block content entity. Creating new referenced entities works fine, but if I try to update an existing entity the data is lost. I traced this to EntityReferenceItem::getValue() which calls ::hasNewEntity() to decide whether to attach the entity property; this doesn't take new revisions into account. Then later in ::preSave() we also have to explicitly save the new revision, as the parent ::preSave() only cares about new entities.

    The attached patch solves the bug in this situation for me.

Production build 0.71.5 2024