Commit b6fa1ca0 authored by catch's avatar catch
Browse files

Issue #2493091 by Wim Leers: Installing block module should invalidate the 'rendered' cache tag

parent 9ae3c9fb
......@@ -7,6 +7,7 @@
use Drupal\block\BlockInterface;
use Drupal\Component\Utility\Html;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\language\ConfigurableLanguageInterface;
......@@ -306,3 +307,13 @@ function block_configurable_language_delete(ConfigurableLanguageInterface $langu
}
}
}
/**
* Implements hook_install().
*/
function block_install() {
// Because the Block module upon installation unconditionally overrides all
// HTML output by selecting a different page display variant, we must
// invalidate all cached HTML output.
Cache::invalidateTags(['rendered']);
}
<?php
/**
* @file
* Contains \Drupal\block\Tests\BlockInstallTest.
*/
namespace Drupal\block\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests block module's installation.
*
* @group block
*/
class BlockInstallTest extends WebTestBase {
public function testCacheTagInvalidationUponInstallation() {
// Warm the page cache.
$this->drupalGet('');
$this->assertNoText('Powered by Drupal');
$this->assertNoCacheTag('config:block_list');
// Install the block module, and place the "Powered by Drupal" block.
$this->container->get('module_installer')->install(['block', 'shortcut']);
$this->rebuildContainer();
$this->container->get('router.builder')->rebuild();
$this->drupalPlaceBlock('system_powered_by_block');
// Check the same page, block.module's hook_install() should have
// invalidated the 'rendered' cache tag to make blocks show up.
$this->drupalGet('');
$this->assertCacheTag('config:block_list');
$this->assertText('Powered by Drupal');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment