diff --git a/core/modules/block/block.install b/core/modules/block/block.install index a9698e5..f473c23 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -12,6 +12,14 @@ /** * Update block visibility context mapping. + * + * This update function updates blocks for the change of + * https://www.drupal.org/node/2354889 + * + * Core visibility context plugins are updated automatically; blocks with + * unknown plugins are disabled and their previous visibility settings are saved + * in key value storage; see change record https://www.drupal.org/node/2527840 + * for more explanation. */ function block_update_8001() { // These 3 are all the contexts that Drupal core provides. @@ -63,6 +71,8 @@ function block_update_8001() { unset($visibility[$condition_plugin_id]); continue; } + // We replace the previous format of "{$context_id}" + // with "@{$service_id}:{$unqualified_context_id}". $new_context_id = explode('.', $context, 2); $condition['context_mapping'][$key] = '@' . $context_service_id_map[$key] . ':' . $new_context_id[1]; } diff --git a/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php b/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php index 772dfb1..c3de576 100644 --- a/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php +++ b/core/modules/block/src/Tests/Update/BlockContextMappingUpdateTest.php @@ -80,7 +80,7 @@ public function testUpdateHookN() { $disabled_block = Block::load('thirdtestfor2354889'); $this->assertFalse($disabled_block->status(), 'Block with invalid context is disabled'); - $this->assertEqual(['thirdtestfor2354889' => ['missing_context_ids' => 'baloney.spam', 'status' => TRUE]], \Drupal::keyValue('update_backup')->get('block_update_8001')); + $this->assertEqual(['thirdtestfor2354889' => ['missing_context_ids' => ['baloney.spam'], 'status' => TRUE]], \Drupal::keyValue('update_backup')->get('block_update_8001')); $disabled_block_visibility = $disabled_block->get('visibility'); $this->assertTrue(!isset($disabled_block_visibility['node_type']), 'The problematic visibility condition has been removed.');