From c66a78c64cad127113ecc88b7d52977889fbf191 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 25 Jun 2013 20:21:16 +0100
Subject: [PATCH] Issue #2021829 by damiankloip, olli: Fixed Redundant
 executeView() in ViewsBlock::build().

---
 .../block/lib/Drupal/block/Plugin/views/display/Block.php   | 4 +++-
 .../views/lib/Drupal/views/Plugin/Block/ViewsBlock.php      | 6 ++----
 core/modules/views/lib/Drupal/views/ViewExecutable.php      | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
index 4a3bf10ac773..121d2de9c0d0 100644
--- a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
+++ b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php
@@ -54,8 +54,10 @@ public function execute() {
     // display, and arguments should be set on the view.
     $element = $this->view->render();
     if (!empty($this->view->result) || $this->getOption('empty') || !empty($this->view->style_plugin->definition['even empty'])) {
-      return drupal_render($element);
+      return $element;
     }
+
+    return array();
   }
 
   /**
diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
index 2c0481ea2623..270ed26cdc82 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
@@ -11,6 +11,7 @@
 use Drupal\Component\Annotation\Plugin;
 use Drupal\Core\Annotation\Translation;
 use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Component\Utility\Xss;
 
 /**
  * Provides a generic Views block.
@@ -74,14 +75,11 @@ public function form($form, &$form_state) {
    */
   public function build() {
     if ($output = $this->view->executeDisplay($this->displayID)) {
-      $output = $this->view->executeDisplay($this->displayID);
       // Set the label to the title configured in the view.
-      $this->configuration['label'] = filter_xss_admin($this->view->getTitle());
+      $this->configuration['label'] = Xss::filterAdmin($this->view->getTitle());
       // Before returning the block output, convert it to a renderable array
       // with contextual links.
       $this->addContextualLinks($output);
-
-      $this->view->destroy();
       return $output;
     }
 
diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php
index 1e59e2233ae1..25c387e46f10 100644
--- a/core/modules/views/lib/Drupal/views/ViewExecutable.php
+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php
@@ -1333,7 +1333,7 @@ public function render($display_id = NULL) {
   public function executeDisplay($display_id = NULL, $args = array()) {
     if (empty($this->current_display) || $this->current_display != $this->chooseDisplay($display_id)) {
       if (!$this->setDisplay($display_id)) {
-        return FALSE;
+        return NULL;
       }
     }
 
-- 
GitLab