diff --git a/core/modules/block/block.install b/core/modules/block/block.install index 38e9a93..29947f0 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -27,6 +27,9 @@ function block_update_8001() { if ($visibility = $block->get('visibility')) { foreach ($visibility as &$condition) { foreach ($condition['context_mapping'] as $key => $context) { + if (!isset($context_service_id_map[$key])) { + throw new \UnexpectedValueException(sprintf('Encountered an unexpected context mapping key %s', $key)); + } $new_context_id = explode('.', $context, 2); $condition['context_mapping'][$key] = '@' . $context_service_id_map[$key] . ':' . $new_context_id[1]; } diff --git a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php index b7b655f..34a810b 100644 --- a/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php +++ b/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php @@ -11,7 +11,7 @@ $connection = Database::getConnection(); // Structure of a custom block with visibility settings. -$block_config = [ +$block_configs = [[ 'uuid' => '9d204071-a923-4707-8200-c298a540fb0c', 'langcode' => 'en', 'status' => TRUE, @@ -70,17 +70,48 @@ ], ], ], -]; +],[ + 'uuid' => 'C499B41D-035E-432E-9462-36410C43C49F', + 'langcode' => 'en', + 'status' => TRUE, + 'dependencies' => [ + 'module' => [ + 'search', + ], + 'theme' => [ + 'bartik', + ], + ], + 'id' => 'secondtestfor2354889', + 'theme' => 'bartik', + 'region' => 'sidebar_first', + 'weight' => -6, + 'provider' => NULL, + 'plugin' => 'search_form_block', + 'settings' => [ + 'id' => 'search_form_block', + 'label' => 'Search', + 'provider' => 'search', + 'label_display' => 'visible', + 'cache' => [ + 'max_age' => -1, + ], + 'status' => TRUE, + ], + 'visibility' => [], +]]; -$connection->insert('config') - ->fields(array( - 'collection', - 'name', - 'data', - )) - ->values(array( - 'collection' => '', - 'name' => 'block.block.testfor2354889', - 'data' => serialize($block_config), - )) - ->execute(); +foreach ($block_configs as $block_config) { + $connection->insert('config') + ->fields(array( + 'collection', + 'name', + 'data', + )) + ->values(array( + 'collection' => '', + 'name' => 'block.block.' . $block_config['id'], + 'data' => serialize($block_config), + )) + ->execute(); +}