diff --git a/core/modules/node/src/Tests/Views/RowPluginTest.php b/core/modules/node/src/Tests/Views/RowPluginTest.php index 4813bd6..e0e863e 100644 --- a/core/modules/node/src/Tests/Views/RowPluginTest.php +++ b/core/modules/node/src/Tests/Views/RowPluginTest.php @@ -139,9 +139,10 @@ public function testRowPlugin() { // Test with links enabled. $view->rowPlugin->options['links'] = TRUE; \Drupal::entityManager()->getViewBuilder('node')->resetCache(); - $output = $view->preview(); - $output = drupal_render($output); + $build = $view->preview(); + $output = drupal_render($build); $this->drupalSetContent($output); + debug($output); foreach ($this->nodes as $node) { $this->assertTrue($this->xpath('//li[contains(@class, :class)]/a[contains(@href, :href)]', array(':class' => 'node-readmore', ':href' => "node/{$node->id()}")), 'Make sure no readmore link appears.'); } diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 5ff74ba..9acae5c 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -142,8 +142,8 @@ public function cacheSet($type) { \Drupal::cache($this->resultsBin)->set($this->generateResultsKey(), $data, $this->cacheSetExpire($type), $this->getCacheTags()); break; case 'output': - $this->storage['output'] = drupal_render($this->view->display_handler->output); - $this->gatherHeaders(); + $this->gatherHeaders($this->view->display_handler->output); + $this->storage['output'] = drupal_render($this->view->display_handler->output, TRUE); \Drupal::cache($this->outputBin)->set($this->generateOutputKey(), $this->storage, $this->cacheSetExpire($type), $this->getCacheTags()); break; } @@ -177,8 +177,13 @@ public function cacheGet($type) { if ($cache = \Drupal::cache($this->outputBin)->get($this->generateOutputKey())) { if (!$cutoff || $cache->created > $cutoff) { $this->storage = $cache->data; - $this->view->display_handler->output = $cache->data['output']; + $this->restoreHeaders(); + $this->view->display_handler->output = array( + '#attached' => &$this->view->element['#attached'], + '#markup' => $cache->data['output'], + ); + return TRUE; } } @@ -235,7 +240,7 @@ public function cacheStart() { /** * Gather the JS/CSS from the render array, the html head from the band data. */ - protected function gatherHeaders() { + protected function gatherHeaders(array $render_array = []) { // Simple replacement for head if (isset($this->storage['head'])) { $this->storage['head'] = str_replace($this->storage['head'], '', drupal_add_html_head()); @@ -244,7 +249,7 @@ protected function gatherHeaders() { $this->storage['head'] = ''; } - $attached = drupal_render_collect_attached($this->storage['output']); + $attached = drupal_render_collect_attached($render_array, TRUE); $this->storage['css'] = $attached['css']; $this->storage['js'] = $attached['js']; } diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php index c621578..9063ab9 100644 --- a/core/modules/views/src/Plugin/views/display/Feed.php +++ b/core/modules/views/src/Plugin/views/display/Feed.php @@ -94,7 +94,7 @@ public function preview() { if (!empty($this->view->live_preview)) { $output = array( '#prefix' => '
',
-        '#markup' => String::checkPlain($output),
+        '#markup' => String::checkPlain(drupal_render($output)),
         '#suffix' => '
', ); } diff --git a/core/modules/views/src/Plugin/views/style/Opml.php b/core/modules/views/src/Plugin/views/style/Opml.php index 11b359c..7080edb 100644 --- a/core/modules/views/src/Plugin/views/style/Opml.php +++ b/core/modules/views/src/Plugin/views/style/Opml.php @@ -83,7 +83,7 @@ public function render() { '#rows' => $rows, ); unset($this->view->row_index); - return drupal_render($build); + return $build; } } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index d81680e..42f0e77 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1308,6 +1308,7 @@ public function render($display_id = NULL) { $cache = $this->display_handler->getPlugin('cache'); } + /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */ if ($cache && $cache->cacheGet('output')) { } else {