summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2008-01-25 10:56:59 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2008-01-25 10:56:59 +0000
commit2a0f65a7420b7d1bb032d3b2691f74b6ddb4cdb8 (patch)
tree9686fbb6f8edc820dc21b5244feeb3b855ed43a5
parentce8672a73193d43b5cc01639d81fbd0e3d86d656 (diff)
downloadbrdo-2a0f65a7420b7d1bb032d3b2691f74b6ddb4cdb8.tar.gz
brdo-2a0f65a7420b7d1bb032d3b2691f74b6ddb4cdb8.tar.bz2
#211742 by theborg, chx: detect and solve the problem when blocks are assigned to invalid regions (happens in theme development)
-rw-r--r--modules/block/block.module13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index b65713d39..6892199b2 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.