Issue #1022416 by bfroehle, turboflash: Fixed Wrong use of db_transaction() in block module.

8.0.x
webchick 2011-06-08 22:34:15 -07:00
parent 002cf94d32
commit 352fdec02d
1 changed files with 62 additions and 50 deletions

View File

@ -170,8 +170,8 @@ function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_r
* @see block_admin_display_form() * @see block_admin_display_form()
*/ */
function block_admin_display_form_submit($form, &$form_state) { function block_admin_display_form_submit($form, &$form_state) {
$txn = db_transaction(); $transaction = db_transaction();
try {
foreach ($form_state['values']['blocks'] as $block) { foreach ($form_state['values']['blocks'] as $block) {
$block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE); $block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE);
$block['region'] = $block['status'] ? $block['region'] : ''; $block['region'] = $block['status'] ? $block['region'] : '';
@ -186,6 +186,12 @@ function block_admin_display_form_submit($form, &$form_state) {
->condition('theme', $block['theme']) ->condition('theme', $block['theme'])
->execute(); ->execute();
} }
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('block', $e);
throw $e;
}
drupal_set_message(t('The block settings have been updated.')); drupal_set_message(t('The block settings have been updated.'));
cache_clear_all(); cache_clear_all();
} }
@ -460,8 +466,8 @@ function block_admin_configure_validate($form, &$form_state) {
*/ */
function block_admin_configure_submit($form, &$form_state) { function block_admin_configure_submit($form, &$form_state) {
if (!form_get_errors()) { if (!form_get_errors()) {
$txn = db_transaction(); $transaction = db_transaction();
try {
db_update('block') db_update('block')
->fields(array( ->fields(array(
'visibility' => (int) $form_state['values']['visibility'], 'visibility' => (int) $form_state['values']['visibility'],
@ -500,6 +506,12 @@ function block_admin_configure_submit($form, &$form_state) {
} }
module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']); module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']);
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('block', $e);
throw $e;
}
drupal_set_message(t('The block configuration has been saved.')); drupal_set_message(t('The block configuration has been saved.'));
cache_clear_all(); cache_clear_all();
$form_state['redirect'] = 'admin/structure/block'; $form_state['redirect'] = 'admin/structure/block';