#211742 by theborg, chx: detect and solve the problem when blocks are assigned to invalid regions (happens in theme development)

6.x
Gábor Hojtsy 2008-01-25 10:56:59 +00:00
parent ce8672a731
commit 2a0f65a742
1 changed files with 11 additions and 2 deletions

View File

@ -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.