- Merge request !38Issue #3002175: Custom blocks created in inline forms should not be reusable β (Open) created by alt.dev
- last update
over 1 year ago 1 pass, 16 fail - last update
11 months ago PHPLint Failed - πΊπ¦Ukraine alt.dev
I made a fix when nested blocks added via the inline_entity_form module didn't have the edit button visible when you edit the block. Also, this fix fixes the issue when you can't see nested blocks while the node is not saved.
This patch can be applied to Drupal 10.2.x.
- πΊπΈUnited States adam-delaney
> The LB module declares its event subscriber in a ServiceProvider class instead of in its .services.yml file. This is because it is conditional: it should only be defined if the block_content module is enabled. This patch just declares the subscriber in the .service.yml file, but perhaps it would be better to use a ServiceProvider class. I have not tested whether this patch causes problems when LB is not enabled.
I've tested this with a new site install that does not enable block_content and this will throw the following error: `Error: Class "Drupal\block_content\BlockContentEvents" not found in Drupal\inline_entity_form\EventSubscriber\SetInlineBlockDependencyNested::getSubscribedEvents()`
- πΊπΈUnited States adam-delaney
I've created a new patch from patch 44 that removes the services.yml in favor of a ServiceProvider that dynamically defines inline_entity_form.get_block_dependency_subscriber if block_content is enabled. I have also checked that block_content is enabled in hook_entity_presave() as that was erroring as well.
- πΊπΈUnited States froboy Chicago, IL
If you have a bunch of existing blocks it may be useful to run an update hook to set the them all to be non-reusable. Here's what I did so it might help others:
/** * Set blocks that should not be reusable to non-reusable. */ function my_module_update_9001(&$sandbox) { $count = 0; $block_storage = \Drupal::service('entity_type.manager')->getStorage('block_content'); $ids = \Drupal::entityQuery('block_content') ->condition(/* Some condition if you're able to identify only certain block types to fix. */) ->condition('reusable', '1', '=') ->accessCheck(FALSE) ->execute(); foreach ($ids as $id) { // Loop through blocks and set them to non-reusable. /** @var \Drupal\block_content\Entity\BlockContent $updated */ $block = $block_storage->load($id); $updated = $block->setNonReusable()->save(); if ($updated == 2) { $count++; } } \Drupal::messenger() ->addMessage(t('Updated @count blocks.', [ '@count' => $count, ])); }
- Status changed to Needs work
7 months ago 1:53pm 16 May 2024 - πΊπΈUnited States froboy Chicago, IL
Reopening this for consideration on the 3.x branch. I think it could be a useful addition. Will try to come back to it with updates if it's wanted.
- πΊπΈUnited States adam-delaney
Patch #46 breaks due to upstream change in Drupal Core 10.3 InlineBlockEntityOperations, see commit: https://git.drupalcode.org/project/drupal/-/commit/71a1ab746b9731cb30213.... This change removes the parent getPluginBlockId method and causes a WSOD. It looks like that method was getting the plugin id from configuration so the patch could likely be updated to code around this. I don't see this patch as long term viable unless core allows for these classes and services to be open to contrib projects so we are planning on getting out of this patch.
- πΊπΈUnited States froboy Chicago, IL
@adam-delaney thanks for the warning.
- First commit to issue fork.
- π¨π¦Canada arakwar
I tested one of our project without the patch and it created more issues for us.
I added the missing function back in the module. I also applied patch #46 on MR !38, just to make it easier to continue to work on this issue until it's resolved.