diff --git a/modules/block/block.module b/modules/block/block.module index b65713d39ab20edfd9dcd248ff31a0a7cdb4b85d..6892199b27639e58216e500d2815b768d57c0502 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -235,6 +235,8 @@ function _block_rehash() { } $blocks = array(); + // Valid region names for the theme. + $regions = system_region_list($theme_key); foreach (module_list() as $module) { $module_blocks = module_invoke($module, 'block', 'list'); @@ -265,8 +267,15 @@ function _block_rehash() { // do not need to update the database here. // Add 'info' to this block. $old_blocks[$module][$delta]['info'] = $block['info']; - // Set region to none if not enabled. - $old_blocks[$module][$delta]['region'] = $old_blocks[$module][$delta]['status'] ? $old_blocks[$module][$delta]['region'] : BLOCK_REGION_NONE; + // If the region name does not exist, disable the block and assign it to none. + if (!empty($old_blocks[$module][$delta]['region']) && !isset($regions[$old_blocks[$module][$delta]['region']])) { + drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $old_blocks[$module][$delta]['info'], '%region' => $old_blocks[$module][$delta]['region'])), 'warning'); + $old_blocks[$module][$delta]['status'] = 0; + $old_blocks[$module][$delta]['region'] = BLOCK_REGION_NONE; + } + else { + $old_blocks[$module][$delta]['region'] = $old_blocks[$module][$delta]['status'] ? $old_blocks[$module][$delta]['region'] : BLOCK_REGION_NONE; + } // Add this block to the list of blocks we return. $blocks[] = $old_blocks[$module][$delta]; // Remove this block from the list of blocks to be deleted.