diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index 75ff6d3..e6b42a1 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -105,12 +105,11 @@ function custom_block_delete_form($form, &$form_state, CustomBlock $block) { '#value' => $instances, ); - if (!empty($instances)) { - $form['message'] = array( - '#type' => 'markup', - '#markup' => format_plural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'), - ); - } + $form['message'] = array( + '#type' => 'markup', + '#markup' => format_plural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'), + '#access' => !empty($instances), + ); return confirm_form( $form, diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index baf239e..5bb5e81 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -147,4 +147,22 @@ public function testBlockDelete() { $this->assertNoRaw('Error message'); } + /** + * Test deleting a block with no instances. + */ + public function testBlockDeleteNoInstances() { + // Create a block. + $edit = array(); + $langcode = Language::LANGCODE_NOT_SPECIFIED; + $edit['info'] = $this->randomName(8); + $body = $this->randomName(16); + $edit["block_body[$langcode][0][value]"] = $body; + $this->drupalPost('block/add/basic', $edit, t('Save')); + + // Delete the block. + $this->drupalGet('block/1/delete'); + + $this->assertNoText('This will also remove'); + } + }