From 4fd0af5510bde88b36d1a8790d3a5cd2d207dc85 Mon Sep 17 00:00:00 2001 From: webchick Date: Fri, 1 Feb 2013 19:42:21 -0800 Subject: [PATCH] Issue #1893818 by Berdir: Fixed Plugin discovery caches of blocks are not cleared for all languages. --- .../Tests/AggregatorLanguageBlockTest.php | 86 +++++++++++++++++++ .../Drupal/block/Plugin/Type/BlockManager.php | 3 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorLanguageBlockTest.php diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorLanguageBlockTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorLanguageBlockTest.php new file mode 100644 index 00000000000..9e9d8fe9117 --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorLanguageBlockTest.php @@ -0,0 +1,86 @@ + '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); + } + } +} diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index c97775681d0..91951a937e8 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -8,6 +8,7 @@ namespace Drupal\block\Plugin\Type; 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 @@ class BlockManager extends PluginManagerBase { $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')); } /**