Pull merge.
[yaffs-website] / web / core / modules / block / src / BlockListBuilder.php
index c1ccc504dbcacc811770079ef20b7c60ed26e105..d2286fcdd3644cd9b90a490a45e0a3cb399e31b7 100644 (file)
@@ -354,6 +354,23 @@ class BlockListBuilder extends ConfigEntityListBuilder implements FormInterface
 
     if (isset($operations['delete'])) {
       $operations['delete']['title'] = $this->t('Remove');
+      // Block operation links should have the `block-placement` query string
+      // parameter removed to ensure that JavaScript does not receive a block
+      // name that has been recently removed.
+      foreach ($operations as $operation) {
+        /** @var \Drupal\Core\Url $url */
+        $url = $operation['url'];
+        $query = $url->getOption('query');
+        $destination = $query['destination'];
+
+        $destinationUrl = Url::fromUserInput($destination);
+        $destinationQuery = $destinationUrl->getOption('query');
+        unset($destinationQuery['block-placement']);
+
+        $destinationUrl->setOption('query', $destinationQuery);
+        $query['destination'] = $destinationUrl->toString();
+        $url->setOption('query', $query);
+      }
     }
     return $operations;
   }