Skip to content
Snippets Groups Projects
Commit 4fd0af55 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1893818 by Berdir: Fixed Plugin discovery caches of blocks are not...

Issue #1893818 by Berdir: Fixed Plugin discovery caches of blocks are not cleared for all languages.
parent 9d356a43
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
/**
* @file
* Contains \Drupal\aggregator\Tests\AggregatorLanguageBlockTest.
*/
namespace Drupal\aggregator\Tests;
use Drupal\Core\Language\Language;
/**
* Tests multilingual block definition caching.
*/
class AggregatorLanguageBlockTest extends AggregatorTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('block', 'language');
/**
* List of langcodes.
*
* @var array
*/
protected $langcodes = array();
public static function getInfo() {
return array(
'name' => 'Multilingual blocks',
'description' => 'Checks display of aggregator blocks with multiple languages.',
'group' => 'Aggregator',
);
}
public function setUp() {
parent::setUp();
// Create test languages.
$this->langcodes = array(language_load('en'));
for ($i = 1; $i < 3; ++$i) {
$language = new Language(array(
'langcode' => 'l' . $i,
'name' => $this->randomString(),
));
language_save($language);
$this->langcodes[$i] = $language;
}
}
/**
* Creates a block in a language, check blocks page in all languages.
*/
public function testBlockLinks() {
// Create admin user to be able to access block admin.
$admin_user = $this->drupalCreateUser(array(
'administer blocks',
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
'administer languages',
));
$this->drupalLogin($admin_user);
// Create the block cache for all languages.
foreach ($this->langcodes as $langcode) {
$this->drupalGet('admin/structure/block', array('language' => $langcode));
$this->clickLink(t('Add block'));
}
// Create a feed in the default language.
$this->createSampleNodes();
$feed = $this->createFeed();
// Check that the block is listed for all languages.
foreach ($this->langcodes as $langcode) {
$this->drupalGet('admin/structure/block', array('language' => $langcode));
$this->clickLink(t('Add block'));
$this->assertText($feed->title);
}
}
}
......@@ -8,6 +8,7 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
......@@ -30,7 +31,7 @@ public function __construct() {
$this->discovery = new AnnotatedClassDiscovery('block', 'block');
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'block');
$this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache_block');
$this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache_block', CacheBackendInterface::CACHE_PERMANENT, array('block'));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment