Inline blocks from layout builder not cloned properly

Created on 10 December 2019, about 5 years ago
Updated 19 January 2023, about 2 years ago

Prerequisite
Enable layout builder on Content type(s) and allow user to place custom blocks on node layout.

Problem
When a node with layout builder enabled and has custom (inline) blocks placed in its layout. When that node is cloned, separate instances of inline blocks are not created. If a user edits the inline blocks in the cloned page, then go back to the original page, the blocks on the original page will be locked for edits.

Steps to reproduce
1. Enable layout builder
2. Create a custom block type, with simple text fields.
3. Create a content type
4. In Manage Display, enable "Use Layout Builder" and "Allow each content item to have its layout customized."
5. In "BLOCKS AVAILABLE FOR PLACEMENT", allow placement of custom blocks
6. Create test node, in [node_path]/layout, add a block and select create custom block and select the block type you created
7. Save layout.
8. Clone node
9. In the cloned node, go to [node_path]/layout, edit the block and save
10. Go back to the original node layout ([node_path]/layout), try to edit the block and save. See warning messages

Expected behavior
When a node is cloned, user should be able to edit inline blocks on either the original or the clone version of the node.

What happened instead
When a node is clone, as soon as user edits the inline block on clone version of the node, inline blocks on original version of the node will be locked.

๐Ÿ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada Weilinggu

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.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium weseze

    Rerolled patch from #28 against latest release.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    3 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xaqrox Washington, D.C.

    Was using the previous patch on a project that included blocks with paragraphs, and we had a similar problem again: cloned blocks were referencing the same paragraphs as their source nodes. Editing paragraphs seemed to work since the actual field refers to revisions, but if you deleted one of the blocks the paragraph would be deleted as well. Here's a patch that includes cloning the paragraphs of the cloned blocks (and some slightly opinionated refactoring of the cloneParagraphs function).

  • Issue was unassigned.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Webbeh Georgia, USA

    Please include interdiffs when creating a new patch, or use the fork/MR functionality so folks can easily follow what changes have been made between contributions. Thanks!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xaqrox Washington, D.C.

    My bad! Here's the interdiff.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nsciacca

    Patch in #32 worked for me. I had Layout Builder blocks referencing paragraphs and found that cloned nodes that were unpublished were setting the source node's paragraphs to be unpublished - so anonymous visitors would see a blank page visiting the source node. This is working, thank you.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    Just looked into this issue again. We might be able to remove the duplicate save with ๐Ÿ› Cloned entities don't retain their Inline Block usage Needs work .

    About cloning entities (nested), our lives would be a lot easier if we have ๐Ÿ› It is not possible to react to an entity being duplicated Needs work .

    To fix the (nested) cloning of paragraphs we have โœจ Paragraph Library supports Entity Clone module Needs work . If we can make the paragraphs module support hook_entity_duplicate_create(), all the clone related modules would be a lot simpler.

    We could even have a core issue to make layout builder implement hook_entity_duplicate_create(), so the layout builder module is responsible for cloning all the blocks when an entity contains a layout builder field.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xaqrox Washington, D.C.

    #32 updated for 1.17/current 1.x

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States markdorison

    Could we please convert this work to a merge request so that GitLabCI will run against it?

  • Merge request !22Apply patch from issue #3100117 โ†’ (Open) created by xaqrox
  • Pipeline finished with Failed
    about 1 year ago
    #80878
  • First commit to issue fork.
  • Pipeline finished with Failed
    12 months ago
    Total: 214s
    #96902
  • Pipeline finished with Failed
    12 months ago
    Total: 255s
    #96914
  • Pipeline finished with Success
    12 months ago
    Total: 248s
    #96924
  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv
  • Pipeline finished with Failed
    12 months ago
    Total: 210s
    #97283
  • Pipeline finished with Canceled
    12 months ago
    #97295
  • Pipeline finished with Success
    12 months ago
    Total: 176s
    #97296
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada phjou Vancouver ๐Ÿ‡จ๐Ÿ‡ฆ ๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium RandalV

    @phjou Strange, if you use `.diff` instead, then it does work.
    https://git.drupalcode.org/project/quick_node_clone/-/merge_requests/22/...

    Make sure to add an empty line at EOF, though.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia codersrini Chennai

    The fix #43 worked for me. Thanks a lot.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    Would it be possible to move cloneParagraphs, cloneInlineBlocks to a separate service so it can be used in other code/modules? It would also be nice to move the code to clone a specific section to a separate cloneSection method. I'm currently adding a custom controller that duplicates the code to clone a specific section in a layout, and it would be nice to reuse the code we have here.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    This seems to do it. Updated the MR.

  • Pipeline finished with Failed
    9 months ago
    Total: 246s
    #175614
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States codechefmarc

    Just FYI, I needed to update from 1.16 to 1.18 and the original patch we had didn't work for the new version. So, I removed the patch and decided to test this issue and it all seemed to work fine. Was this fixed from 1.16 to 1.18?

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    Added a commit to fix an issue while cloning layout builder content for the default language. It appears InlineBlockEntityOperations::handlePreSave does not run for syncing entities.

  • Pipeline finished with Failed
    3 months ago
    Total: 171s
    #328610
  • First commit to issue fork.
  • Pipeline finished with Success
    3 months ago
    Total: 288s
    #332952
  • Pipeline finished with Failed
    3 months ago
    Total: 211s
    #332971
  • Pipeline finished with Failed
    3 months ago
    Total: 192s
    #332977
  • Pipeline finished with Failed
    3 months ago
    Total: 200s
    #332979
  • Pipeline finished with Failed
    3 months ago
    Total: 199s
    #332986
  • Pipeline finished with Success
    3 months ago
    Total: 192s
    #333002
  • Pipeline finished with Failed
    3 months ago
    Total: 270s
    #333014
  • Pipeline finished with Success
    3 months ago
    Total: 260s
    #333019
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv

    taran2l โ†’ changed the visibility of the branch 8.x-1.x to hidden.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv

    I've removed all refactoring to make everything a little bit easier to review and added a BC layer for the service constructor arguments change

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    The changes in cloneParagraphs are not entirely unrelated. For example, cloneParagraphs only allowed cloning paragraphs in nodes, while inline blocks can also contain paragraphs. Can you revert your changes to cloneParagraphs?

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv
  • First commit to issue fork.
  • Pipeline finished with Success
    2 months ago
    Total: 259s
    #345295
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dblanken Carmel, Indiana

    I made cloneParagraph's parameter mixed so that it won't bomb on things like BlockContent, which also calls that method. This still feels like a bandaid, but allows my sites to work. Are there other types we should be looking out for to be explicit and replace mixed?

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands seanB Netherlands

    The parameter should probably be FieldableEntityInterface, I think we should just revert commit https://git.drupalcode.org/project/quick_node_clone/-/commit/4b2e8cbbb1f...

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv

    hi @dblanken @seanb

    I've added FieldableEntityInterface back, the original change is doing a good refactoring, but it out of scope for this issue imo and makes it harder to understand and review (plus it's harder to combine patches)

  • Pipeline finished with Success
    2 months ago
    Total: 194s
    #345722
  • Pipeline finished with Success
    2 months ago
    Total: 314s
    #345724
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Taran2L Lviv
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dblanken Carmel, Indiana

    Hi @taran2l

    Thank you very much. I can confirm that with the FieldableEntityInterface it's working for us again. Thanks a lot for doing that.

  • Assigned to Taran2L
  • ๐Ÿ‡ท๐Ÿ‡บRussia kiseleva.t

    kiseleva.t โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    17 days ago
    Total: 405s
    #394196
Production build 0.71.5 2024