Problem:
Cache setting “Block caching type” is not used in block instances. Instead DRUPAL_NO_CACHE is used.

How to reproduce:

  • Create Views block display.
  • Set cache to any value (except “Do not cache”).
  • Save View.
  • Place View block with any machine name.
  • You can see placed block settings in sites/default/files/config_[hash]/active/block.block.bartik.[machine_name].yml
    Cache setting with be always -1 (DRUPAL_NO_CACHE).

Now 'cache' and 'admin_label' is added via Drupal\views\Plugin\Derivative\ViewsBlock, but only admin label is added to settings by default: http://drupalcode.org/project/drupal.git/blob/50ae3296382669baebee8b9afa...

Solution:
Add cache setting in settings() method.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kalabro’s picture

Status: Active » Needs review
FileSize
765 bytes

Status: Needs review » Needs work

The last submitted patch, 1987236-drupal_8_views_block_cache.patch, failed testing.

kalabro’s picture

Status: Needs work » Needs review

Failed NodeAccessLanguageTest is not related to this patch.

msonnabaum’s picture

Priority: Normal » Major

Just ran into this as well. This is clearly missing test coverage considering it's been broken this long.

dawehner’s picture

Issue tags: +VDC
FileSize
1.45 KB
2.59 KB

Note: never forget the VDC tag.

Status: Needs review » Needs work

The last submitted patch, block_cache-1987236-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
614 bytes
2.65 KB

If ?: would just handle the isset case.

Wim Leers’s picture

7: vdc-1987236-7.patch queued for re-testing.

damiankloip’s picture

+++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
@@ -49,9 +49,12 @@ public function settings() {
+    $settings['cache'] = isset($this->pluginDefinition['cache']) ? $this->pluginDefinition['cache'] : DRUPAL_NO_CACHE;

That value will be defaulted in BlockBase anyway. I think this would be better as:

if (isset($this->pluginDefinition['cache'])) {
  $settings['cache'] = $this->pluginDefinition['cache'];
}

Otherwise, looks great.

dawehner’s picture

Title: Views block cache setting doesn't work » [regression] Views block cache setting doesn't work
Issue summary: View changes
Issue tags: +front-end performance
FileSize
2.54 KB

PERFORMANCE/REGRESSION HAMMER TIME!

dawehner’s picture

FileSize
2.54 KB
2.54 KB

That was the wrong patch.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Patch is fine and tests show it is working. Great work @dawehner.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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

YesCT’s picture

Issue tags: -front-end performance +frontend performance

changing to use the more common tag, so the less common one can be deleted, so it does not show up in the auto complete and confuse people.