From f048b4a1d0b3631c268ffb0efdffec896efb8439 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 16 Dec 2013 01:04:13 +0000
Subject: [PATCH] Issue #2156351 by olli: Unable to delete block.

---
 .../block/lib/Drupal/block/BlockFormController.php     |  5 +++++
 .../modules/block/lib/Drupal/block/Tests/BlockTest.php | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index 5965c21cca25..92bbe88ccc12 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -350,6 +350,11 @@ public function delete(array $form, array &$form_state) {
         'block' => $this->entity->id(),
       ),
     );
+    $query = $this->getRequest()->query;
+    if ($query->has('destination')) {
+      $form_state['redirect_route']['options']['query']['destination'] = $query->get('destination');
+      $query->remove('destination');
+    }
   }
 
   /**
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index 486efcd8d82f..af49957b00b2 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -141,6 +141,16 @@ function testBlock() {
     $this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block['settings[label]'])));
     $this->drupalPostForm(NULL, array(), t('Delete'));
     $this->assertRaw(t('The block %name has been removed.', array('%name' => $block['settings[label]'])));
+
+    // Test deleting a block via "Configure block" link.
+    $block = $this->drupalPlaceBlock('system_powered_by_block');
+    $this->drupalGet('admin/structure/block/manage/' . $block->id(), array('query' => array('destination' => 'admin')));
+    $this->drupalPostForm(NULL, array(), t('Delete'));
+    $this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block->label())));
+    $this->drupalPostForm(NULL, array(), t('Delete'));
+    $this->assertRaw(t('The block %name has been removed.', array('%name' => $block->label())));
+    $this->assertUrl('admin');
+    $this->assertNoRaw($block->id());
   }
 
   /**
-- 
GitLab