Issue #2449069 by Berdir: Remove default block_plugin cache tags, because they're useless

8.0.x
Alex Pott 2015-03-10 09:20:59 +00:00
parent 1506a99ff4
commit 809854e005
6 changed files with 2 additions and 35 deletions

View File

@ -370,10 +370,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
* {@inheritdoc}
*/
public function getCacheTags() {
// If a block plugin's output changes, then it must be able to invalidate a
// cache tag that affects all instances of this block: across themes and
// across regions.
return array('block_plugin:' . str_replace(':', '__', $this->getPluginID()));
return [];
}
/**

View File

@ -58,7 +58,6 @@ class AggregatorRenderingTest extends AggregatorTestBase {
$this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href)));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('block_plugin:aggregator_feed_block', $cache_tags));
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
// Visit that page.

View File

@ -330,7 +330,6 @@ class BlockTest extends BlockTestBase {
'config:block_list',
'block_view',
'config:block.block.powered',
'block_plugin:system_powered_by_block',
'rendered',
);
sort($expected_cache_tags);
@ -339,7 +338,6 @@ class BlockTest extends BlockTestBase {
$expected_cache_tags = array(
'block_view',
'config:block.block.powered',
'block_plugin:system_powered_by_block',
'rendered',
);
sort($expected_cache_tags);
@ -371,7 +369,6 @@ class BlockTest extends BlockTestBase {
'block_view',
'config:block.block.powered',
'config:block.block.powered-2',
'block_plugin:system_powered_by_block',
'rendered',
);
sort($expected_cache_tags);
@ -379,7 +376,6 @@ class BlockTest extends BlockTestBase {
$expected_cache_tags = array(
'block_view',
'config:block.block.powered',
'block_plugin:system_powered_by_block',
'rendered',
);
sort($expected_cache_tags);
@ -388,19 +384,12 @@ class BlockTest extends BlockTestBase {
$expected_cache_tags = array(
'block_view',
'config:block.block.powered-2',
'block_plugin:system_powered_by_block',
'rendered',
);
sort($expected_cache_tags);
$cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:en:classy');
$this->assertIdentical($cache_entry->tags, $expected_cache_tags);
// The plugin providing the "Powered by Drupal" block is modified; verify a
// cache miss.
Cache::invalidateTags(array('block_plugin:system_powered_by_block'));
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
// Now we should have a cache hit again.
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');

View File

@ -215,7 +215,7 @@ class BlockViewBuilderTest extends KernelTestBase {
$request->setMethod('GET');
$default_keys = array('entity_view', 'block', 'test_block');
$default_tags = array('block_view', 'config:block.block.test_block', 'block_plugin:test_cache');
$default_tags = array('block_view', 'config:block.block.test_block');
// Advanced: cached block, but an alter hook adds an additional cache key.
$this->setBlockCacheConfig(array(

View File

@ -53,7 +53,6 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
'block_view',
'config:block_list',
'config:block.block.' . $block->id(),
'block_plugin:system_menu_block__llama',
'config:system.menu.llama',
);
$this->verifyPageCache($url, 'HIT', $expected_tags);

View File

@ -94,14 +94,6 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'config:block.block.bartik_powered',
'config:block.block.bartik_main_menu',
'config:block.block.bartik_account_menu',
'block_plugin:system_breadcrumb_block',
'block_plugin:system_main_block',
'block_plugin:system_menu_block__account',
'block_plugin:system_menu_block__main',
'block_plugin:system_menu_block__tools',
'block_plugin:user_login_block',
'block_plugin:system_menu_block__footer',
'block_plugin:system_powered_by_block',
'node_view',
'node:' . $node_1->id(),
'user:' . $author_1->id(),
@ -127,15 +119,6 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'config:block.block.bartik_powered',
'config:block.block.bartik_main_menu',
'config:block.block.bartik_account_menu',
'block_plugin:system_breadcrumb_block',
'block_plugin:system_main_block',
'block_plugin:system_menu_block__account',
'block_plugin:system_menu_block__main',
'block_plugin:system_menu_block__tools',
'block_plugin:user_login_block',
'block_plugin:views_block__comments_recent-block_1',
'block_plugin:system_menu_block__footer',
'block_plugin:system_powered_by_block',
'node_view',
'node:' . $node_2->id(),
'user:' . $author_2->id(),