.../src/Plugin/views/cache/CachePluginBase.php | 36 ++-------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 1369b8a..a5bcdad 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -143,8 +143,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->gatherRenderMetadata($this->view->display_handler->output); + $markup = drupal_render($this->view->display_handler->output); + $this->storage['output'] = \Drupal::service('renderer')->getCacheableData($markup, $this->view->display_handler->output); \Drupal::cache($this->outputBin)->set($this->generateOutputKey(), $this->storage, $this->cacheSetExpire($type), $this->getCacheTags()); break; } @@ -178,16 +178,7 @@ public function cacheGet($type) { if ($cache = \Drupal::cache($this->outputBin)->get($this->generateOutputKey())) { if (!$cutoff || $cache->created > $cutoff) { $this->storage = $cache->data; - - $this->restoreRenderMetadata(); - $this->view->display_handler->output = array( - '#attached' => &$this->view->element['#attached'], - '#cache' => [ - 'tags' => &$this->view->element['#cache']['tags'], - ], - '#post_render_cache' => &$this->view->element['#post_render_cache'], - '#markup' => $cache->data['output'], - ); + $this->view->display_handler->output = $this->storage['output']; return TRUE; } @@ -235,27 +226,6 @@ public function postRender(&$output) { } public function cacheStart() { } /** - * Gather bubbleable render metadata from the render array. - * - * @param array $render_array - * The view render array to collect data from. - */ - protected function gatherRenderMetadata(array $render_array = []) { - $this->storage['attachments'] = $render_array['#attached']; - $this->storage['postRenderCache'] = $render_array['#post_render_cache']; - $this->storage['cacheTags'] = $render_array['#cache']['tags']; - } - - /** - * Restore bubbleable render metadata. - */ - public function restoreRenderMetadata() { - $this->view->element['#attached'] = drupal_merge_attached($this->view->element['#attached'], $this->storage['attachments']); - $this->view->element['#cache']['tags'] = Cache::mergeTags(isset($this->view->element['#cache']['tags']) ? $this->view->element['#cache']['tags'] : [], $this->storage['cacheTags']); - $this->view->element['#post_render_cache'] = NestedArray::mergeDeep(isset($this->view->element['#post_render_cache']) ? $this->view->element['#post_render_cache'] : [], $this->storage['postRenderCache']); - } - - /** * Calculates and sets a cache ID used for the result cache. * * @return string