Replicating node with non-reusable block added via layout builder does not replicate the block

Created on 12 December 2019, almost 5 years ago
Updated 28 March 2023, over 1 year ago

Problem/Motivation

Replicating a node controlled by layout builder with a custom block added (non-reusable) should replicate the block as well. This is because by design, these blocks are not reusable.

The same issue exists in entity_clone.

Proposed resolution

Replicate any non-reusable blocks referenced by layout builder when replicating a piece of content.

Completed steps

Next steps

  • Push to RTBC and commit to project.
✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

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.

  • First commit to issue fork.
  • Status changed to Fixed over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Only had a cursory look at this, but looks sensible. This is hardcoded to that specific plugin, but if other types of blocks need special treatment too we could always add an event or so in there.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Follow-up comment: Lets try to get πŸ› It is not possible to react to an entity being duplicated Needs work into core, so that core/layout builder can do its own house-keeping and contrib doesn't need hold its hands so much. And kind of remove the need for this module in the first place as well ;)

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States papagrande US West Coast

    I just updated to 8.x-1.1 and am now getting this fatal error:

    The website encountered an unexpected error. Please try again later.
    Error: Class "Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage" not found in Drupal\replicate\EventSubscriber\ReplicateLayoutBuilderSubscriber->onReplicateAfterSave() (line 82 of modules/contrib/replicate/src/EventSubscriber/ReplicateLayoutBuilderSubscriber.php).
    Drupal\replicate\EventSubscriber\ReplicateLayoutBuilderSubscriber->onReplicateAfterSave(Object, 'replicate__after_save', Object)
    call_user_func(Array, Object, 'replicate__after_save', Object) (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'replicate__after_save') (Line: 100)
    Drupal\replicate\Replicator->replicateEntity(Object) (Line: 117)
    Drupal\replicate_ui\Form\ReplicateConfirmForm->submitForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 595)
    Drupal\Core\Form\FormBuilder->processForm('node_trust_center_page_replicate_form', Array, Object) (Line: 323)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    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: 169)
    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: 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: 718)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    The content node does get replicated.

    Enabling the layout_builder module gets rid of the error, but that module should not be required.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Ah, that again. we need to add the event subsscriber only if the module is enabled, either in the getsubscribed events method or by adding the whole service only in a serviceprovider classes.

    That said, since this was committed and released, pleases create a new issue and reference it here.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024