Skip to content
Snippets Groups Projects
Commit c27f564e authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #77924 by RobRoy: fixed race condition in block administration that...

- Patch #77924 by RobRoy: fixed race condition in block administration that might have caused data loss.
parent 7178f2f9
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment