diff --git a/core/modules/block/block.install b/core/modules/block/block.install index 63b3784..8f98cbc 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -6,20 +6,25 @@ */ /** - * Implements hook_update_N(). + * Disables blocks that are placed into the "disabled" region. */ function block_update_8001() { - // Load all blocks in the disabled region. + // Find all blocks in the disabled region. /** @var \Drupal\block\BlockInterface[] $blocks */ - $blocks = \Drupal::entityManager() + $block_ids = \Drupal::entityManager() ->getStorage('block') - ->loadByProperties(['region' => -1]); + ->getQuery() + ->condition('region', -1) + ->execute(); + + $config_factory = \Drupal::configFactory(); // Disable each block and assign them to the default region. - foreach ($blocks as $block) { - $block - ->disable() - ->setRegion(system_default_region($block->getTheme())) + foreach ($block_ids as $block_id) { + $block_config = $config_factory->getEditable('block.block.' . $block_id); + $block_config + ->set('region', system_default_region($block_config->get('theme'))) + ->set('status', FALSE) ->save(); } }