Problem/Motivation

The \Drupal\views\Plugin\Block\ViewsBlock::build() function contains the following code

if ($output = $this->view->buildRenderable($this->displayID, [], FALSE)) {
  // ...
}

... the FALSE there means that the views output should not be render cached. But it's not clear why we do that; especially since if you look, the block is render-cached.

While trying to track down problems with the block cache, I talked to @dawehner (one of the primary authors of the patch which introduced this call, #2381277: Make Views use render caching and remove Views' own "output caching"), who explained that the real reason why we pass FALSE here is because we don't want to create a dedicated render cache for the view itself. Rather, we want to create a cache for the block only.

Proposed resolution

Since this is not clear, and could be a stumbling block / something that looks like a solution but is not for someone trying to debug render caching, I feel like we should add a short comment to explain why.

Remaining tasks

  1. Write a patch
  2. Review and feedback
  3. RTBC
  4. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 document_why-2633388-2.patch1.12 KBmparker17

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Assigned: mparker17 » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.12 KB

Here is a patch. Feedback welcome.

dawehner’s picture

Category: Feature request » Task
Status: Needs review » Reviewed & tested by the community

Nice!

jhodgdon’s picture

code comments explaining why things are done a certain way +++++ Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 381a888 and pushed to 8.0.x and 8.1.x. Thanks!

  • alexpott committed 46f8d46 on 8.1.x
    Issue #2633388 by mparker17: Document why ViewsBlock::build() explicitly...

  • alexpott committed 381a888 on
    Issue #2633388 by mparker17: Document why ViewsBlock::build() explicitly...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.