= 8002 && !\Drupal::state()->get('block_update_8002_placeholder', FALSE)) { return; } // Cleanup the state entry as its no longer needed. \Drupal::state()->delete('block_update_8002'); $block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []); $block_ids = array_keys($block_update_8001); $block_storage = \Drupal::entityManager()->getStorage('block'); $blocks = $block_storage->loadMultiple($block_ids); /** @var $blocks \Drupal\block\BlockInterface[] */ foreach ($blocks as $block) { // This block has had conditions removed due to an inability to resolve // contexts in block_update_8001() so disable it. // Disable currently enabled blocks. if ($block_update_8001[$block->id()]['status']) { $block->setStatus(FALSE); $block->save(); } } // Provides a list of plugin labels, keyed by plugin ID. $condition_plugin_id_label_map = array_column(\Drupal::service('plugin.manager.condition')->getDefinitions(), 'label', 'id'); // Override with the UI labels we are aware of. Sadly they are not machine // accessible, see // \Drupal\node\Plugin\Condition\NodeType::buildConfigurationForm(). $condition_plugin_id_label_map['node_type'] = t('Content types'); $condition_plugin_id_label_map['request_path'] = t('Pages'); $condition_plugin_id_label_map['user_role'] = t('Roles'); if (count($block_ids) > 0) { $message = t('Encountered an unknown context mapping key coming probably from a contributed or custom module: One or more mappings could not be updated. Please manually review your visibility settings for the following blocks, which are disabled now:'); $message .= '