Allow users to create a block content entity with a specific UUID if it is a missing dependency of a config object

Created on 5 September 2017, almost 8 years ago
Updated 15 July 2023, about 2 years ago

Custom blocks cannot be properly exported and imported Active is pretty nasty in terms of UX but apparently hard to fix.

Basically, if you export a custom block configuration and import this configuration in a new website you will have a "This block is broken or missing" error has the content is effectively missing.

But we perhaps give the user a chance to save is website by replacing:

"This block is broken or missing. You may be missing content or you might need to enable the original module."
by
"'The content of the block (%bundle %uuid) is missing. Add missing content.'.

Proposed resolution

  • Listen to missing content event in block content module.
  • Take note of missing block content UUIDs
  • Store them in state.
  • In the derivative discovery, make definitions available for those UUIDs
  • In the build method for these, output a link with a prebuilt uuid and type (taken from the missing content event stuff that is saved in state)
  • This link will create a stub entity of that type and with that uuid and then present the edit form
  • User submits, hey presto its fixed
  • State entry is cleaned up when block is saved
  • Tests cover that scenario

Remaining tasks

Approach as per comment 37

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Block content 

Last updated 4 days ago

Created by

🇨🇭Switzerland gagarine

Live updates comments and jobs are added and updated live.
  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

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.

  • 🇮🇳India shiks

    If someone is still stuck with synching the block content , then https://www.drupal.org/project/structure_sync module is really something to consider.

    Along with block syncing (which also consider synching the UUID), it also solved the problems of menu, taxonomy synching.

  • 🇦🇺Australia acbramley

    Needs a reroll against 11.x in a new MR.

  • First commit to issue fork.
  • 🇮🇳India ankithashetty Karnataka, India

    MR is ready for 11.x, thanks!

  • Pipeline finished with Failed
    over 1 year ago
    Total: 174s
    #58773
  • Pipeline finished with Failed
    over 1 year ago
    Total: 483s
    #58779
  • Pipeline finished with Failed
    20 days ago
    Total: 293s
    #547485
  • Pipeline finished with Failed
    20 days ago
    Total: 129s
    #547492
  • Pipeline finished with Failed
    20 days ago
    Total: 660s
    #547495
  • 🇦🇺Australia acbramley

    I've rebased the MR and refactored a lot of the new code particularly around constructors/DI as well as return and param types.

    However, I am unable to get this working with manual testing.

    First I tried via enabling a module with a block in the module's config/install folder. With a breakpoint in ConfigImporter::processMissingContent I never hit the breakpoint. Does this event fire for config import via a module's config/install? If not then that's going to be a big issue with the implementation.

    However, I can get a breakpoint on drush cim, but when $this->configManager->findMissingContentDependencies() is called it doesn't find any missing content. Is that because it's reading active storage?

    In both scenarios I just get the default message from the Broken plugin, not from the BlockContentBlock plugin.

  • 🇦🇺Australia acbramley

    Further tested by manually adding the UUID to the state key:

    1. The new route should be an admin route (fixed
    2. The add block form still has the "Save and configure" button - that doesn't make sense in this context as we're adding a block_content entity to resolve a dependency issue in an existing block plugin.
    3. #111 still needs resolving.
    4. The entry in block_content_missing_entities isn't cleared once I've saved the new block_content entity. Not sure if this is a symptom of me adding it manually or not.

  • Pipeline finished with Failed
    20 days ago
    Total: 627s
    #547515
Production build 0.71.5 2024