summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-20 06:49:15 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-20 06:49:15 +0000
commitc27f564e07057b38fe1fb906b68e0e1ccfd9996b (patch)
treef88585772376ea6b60c3c139637963fb73231ca4 /modules
parent7178f2f99e813b2eb6926a562c1448dbc6b715e5 (diff)
downloadbrdo-c27f564e07057b38fe1fb906b68e0e1ccfd9996b.tar.gz
brdo-c27f564e07057b38fe1fb906b68e0e1ccfd9996b.tar.bz2
- Patch #77924 by RobRoy: fixed race condition in block administration that might have caused data loss.
Diffstat (limited to 'modules')
-rw-r--r--modules/block/block.module15
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 07718dc1d..07f03eb9d 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -163,7 +163,7 @@ function _block_rehash() {
$old_blocks[$old_block->module][$old_block->delta] = $old_block;
}
- db_query("DELETE FROM {blocks} WHERE theme = '%s'", $theme_key);
+ $blocks = array();
foreach (module_list() as $module) {
$module_blocks = module_invoke($module, 'block', 'list');
@@ -191,14 +191,21 @@ function _block_rehash() {
}
}
- // Reinsert blocks into table
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)",
- $block['module'], $block['delta'], $theme_key, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
$blocks[] = $block;
}
}
}
+ db_lock_table('blocks');
+ // Remove all blocks from table.
+ db_query("DELETE FROM {blocks} WHERE theme = '%s'", $theme_key);
+
+ // Reinsert new set of blocks into table.
+ foreach ($blocks as $block) {
+ db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", $block['module'], $block['delta'], $theme_key, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
+ }
+ db_unlock_tables();
+
return $blocks;
}