Problem/Motivation

When a custom block has been created, if the user then deletes the custom block using the “delete” contextual link, and then clicks place block again, the block still appears in the list. If the user then tries to add the block the action fails without error message.

Proposed resolution

Remove the block from cache

Remaining tasks

Remove block from cache

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tkoleary created an issue. See original summary.

tkoleary’s picture

larowlan’s picture

Component: block.module » block_content.module
Issue summary: View changes
Issue tags: +Needs tests
larowlan’s picture

Version: 8.2.x-dev » 8.1.x-dev
Assigned: Unassigned » larowlan

Bug fixes go into 8.1.x first - giddyup

larowlan’s picture

Something like so

The last submitted patch, 5: 2786195-delete-block.fail_.patch, failed testing.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks great and have tests!

tim.plunkett’s picture

+++ b/core/modules/block_content/src/Entity/BlockContent.php
@@ -104,9 +104,15 @@ public function getTheme() {
   public function postSave(EntityStorageInterface $storage, $update = TRUE) {
...
+  public static function postDelete(EntityStorageInterface $storage, array $entities) {

We should probably audit all of the entities that have just a postSave, I bet there are other entity classes with mismatches like this (SearchPage comes to mind).

+1 for RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 6bdf44e to 8.3.x and 66fa7be to 8.2.x and 82bece9 to 8.1.x. Thanks!

  • alexpott committed 6bdf44e on 8.3.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...

  • alexpott committed 66fa7be on 8.2.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...

  • alexpott committed 82bece9 on 8.1.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...
andypost’s picture

other entity classes with mismatches like this (SearchPage comes to mind).

What did you mean? please elaborate

andypost’s picture

Also looks a loot patches has failured after this with similar error
For example https://www.drupal.org/pift-ci-job/436365

catch’s picture

Status: Fixed » Needs work

Yes I'm seeing the same. Reverted from all three branches for now.

  • catch committed c90b15c on 8.3.x
    Revert "Issue #2786195 by larowlan: Deleted block is not removed from...

  • catch committed 27ca9e4 on 8.2.x
    Revert "Issue #2786195 by larowlan: Deleted block is not removed from...

  • catch committed b5de575 on 8.1.x
    Revert "Issue #2786195 by larowlan: Deleted block is not removed from...
larowlan’s picture

Yeah, 8.2.x adds revision user to the entity.

larowlan’s picture

Added user support to test, should pass on all three branches now - will queue test runs for each.

The last submitted patch, 5: 2786195-delete-block.pass_.patch, failed testing.

  • catch committed 4221911 on 8.3.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...

  • catch committed 65598a5 on 8.2.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...

  • catch committed a46d123 on 8.1.x
    Issue #2786195 by larowlan: Deleted block is not removed from the block...
catch’s picture

Status: Needs review » Fixed

Thanks! Committed to all three branches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.