View without empty handling could break caching

Created on 3 December 2018, about 6 years ago
Updated 13 June 2024, 6 months ago

When a referenced view does not define a empty handler (for example a little text snippet or so) the referenced view gets cached without any cache information.

This happens because of following code construct in ViewsReferenceFieldFormatter.php

      if (!empty($view->result) || !empty($view->empty)) {
        if ($this->getSetting('plugin_types')) {
          // Add a custom template if the title is available.
          $title = $view->getTitle();
          if (!empty($title)) {
            $elements[$delta]['title'] = [
              '#theme' => 'viewsreference__view_title',
              '#title' => $title,
            ];
          }
        }
        $elements[$delta]['contents'] = $view->buildRenderable($display_id, $view->args, FALSE);
      }

$elements with #cache information is only filled when referenced view returns results or some stuff for empty.

I think $elements should always provide some basic caching information.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany IT-Cru Munich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024