#923826 by catch, carlos8f, moshe weitzman: Fixed entity delete operations should use transactions.
parent
8049f94756
commit
8dd7376d5a
|
@ -1583,7 +1583,8 @@ function comment_delete($cid) {
|
||||||
function comment_delete_multiple($cids) {
|
function comment_delete_multiple($cids) {
|
||||||
$comments = comment_load_multiple($cids);
|
$comments = comment_load_multiple($cids);
|
||||||
if ($comments) {
|
if ($comments) {
|
||||||
|
$transaction = db_transaction();
|
||||||
|
try {
|
||||||
// Delete the comments.
|
// Delete the comments.
|
||||||
db_delete('comment')
|
db_delete('comment')
|
||||||
->condition('cid', array_keys($comments), 'IN')
|
->condition('cid', array_keys($comments), 'IN')
|
||||||
|
@ -1599,6 +1600,12 @@ function comment_delete_multiple($cids) {
|
||||||
_comment_update_node_statistics($comment->nid);
|
_comment_update_node_statistics($comment->nid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
watchdog_exception('comment', $e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ function node_save($node) {
|
||||||
db_ignore_slave();
|
db_ignore_slave();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$transaction->rollback('node');
|
$transaction->rollback();
|
||||||
watchdog_exception('node', $e);
|
watchdog_exception('node', $e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -1164,9 +1164,11 @@ function node_delete($nid) {
|
||||||
* An array of node IDs.
|
* An array of node IDs.
|
||||||
*/
|
*/
|
||||||
function node_delete_multiple($nids) {
|
function node_delete_multiple($nids) {
|
||||||
|
$transaction = db_transaction();
|
||||||
if (!empty($nids)) {
|
if (!empty($nids)) {
|
||||||
$nodes = node_load_multiple($nids, array());
|
$nodes = node_load_multiple($nids, array());
|
||||||
|
|
||||||
|
try {
|
||||||
foreach ($nodes as $nid => $node) {
|
foreach ($nodes as $nid => $node) {
|
||||||
// Call the node-specific callback (if any):
|
// Call the node-specific callback (if any):
|
||||||
node_invoke($node, 'delete');
|
node_invoke($node, 'delete');
|
||||||
|
@ -1196,9 +1198,14 @@ function node_delete_multiple($nids) {
|
||||||
db_delete('node_access')
|
db_delete('node_access')
|
||||||
->condition('nid', $nids, 'IN')
|
->condition('nid', $nids, 'IN')
|
||||||
->execute();
|
->execute();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
watchdog_exception('node', $e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear the page and block and node_load_multiple caches.
|
// Clear the page and block and node_load_multiple caches.
|
||||||
cache_clear_all();
|
|
||||||
entity_get_controller('node')->resetCache();
|
entity_get_controller('node')->resetCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,6 +902,7 @@ function taxonomy_term_confirm_delete_submit($form, &$form_state) {
|
||||||
drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
|
drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
|
||||||
watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
|
watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
|
||||||
$form_state['redirect'] = 'admin/structure/taxonomy';
|
$form_state['redirect'] = 'admin/structure/taxonomy';
|
||||||
|
cache_clear_all();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,6 +942,7 @@ function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
|
||||||
drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
|
drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
|
||||||
watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
|
watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
|
||||||
$form_state['redirect'] = 'admin/structure/taxonomy';
|
$form_state['redirect'] = 'admin/structure/taxonomy';
|
||||||
|
cache_clear_all();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,8 @@ function taxonomy_vocabulary_save($vocabulary) {
|
||||||
function taxonomy_vocabulary_delete($vid) {
|
function taxonomy_vocabulary_delete($vid) {
|
||||||
$vocabulary = taxonomy_vocabulary_load($vid);
|
$vocabulary = taxonomy_vocabulary_load($vid);
|
||||||
|
|
||||||
|
$transaction = db_transaction();
|
||||||
|
try {
|
||||||
// Only load terms without a parent, child terms will get deleted too.
|
// Only load terms without a parent, child terms will get deleted too.
|
||||||
$result = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid = :vid AND th.parent = 0', array(':vid' => $vid))->fetchCol();
|
$result = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid = :vid AND th.parent = 0', array(':vid' => $vid))->fetchCol();
|
||||||
foreach ($result as $tid) {
|
foreach ($result as $tid) {
|
||||||
|
@ -439,6 +441,12 @@ function taxonomy_vocabulary_delete($vid) {
|
||||||
|
|
||||||
return SAVED_DELETED;
|
return SAVED_DELETED;
|
||||||
}
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
watchdog_exception('taxonomy', $e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_taxonomy_vocabulary_update().
|
* Implements hook_taxonomy_vocabulary_update().
|
||||||
|
@ -588,6 +596,8 @@ function taxonomy_term_save($term) {
|
||||||
* Status constant indicating deletion.
|
* Status constant indicating deletion.
|
||||||
*/
|
*/
|
||||||
function taxonomy_term_delete($tid) {
|
function taxonomy_term_delete($tid) {
|
||||||
|
$transaction = db_transaction();
|
||||||
|
try {
|
||||||
$tids = array($tid);
|
$tids = array($tid);
|
||||||
while ($tids) {
|
while ($tids) {
|
||||||
$children_tids = $orphans = array();
|
$children_tids = $orphans = array();
|
||||||
|
@ -620,10 +630,14 @@ function taxonomy_term_delete($tid) {
|
||||||
|
|
||||||
$tids = $orphans;
|
$tids = $orphans;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_clear_all();
|
|
||||||
return SAVED_DELETED;
|
return SAVED_DELETED;
|
||||||
}
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
watchdog_exception('taxonomy', $e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an array for rendering the given term.
|
* Generate an array for rendering the given term.
|
||||||
|
|
|
@ -2361,6 +2361,8 @@ function user_delete_multiple(array $uids) {
|
||||||
if (!empty($uids)) {
|
if (!empty($uids)) {
|
||||||
$accounts = user_load_multiple($uids, array());
|
$accounts = user_load_multiple($uids, array());
|
||||||
|
|
||||||
|
$transaction = db_transaction();
|
||||||
|
try {
|
||||||
foreach ($accounts as $uid => $account) {
|
foreach ($accounts as $uid => $account) {
|
||||||
module_invoke_all('user_delete', $account);
|
module_invoke_all('user_delete', $account);
|
||||||
module_invoke_all('entity_delete', $account, 'user');
|
module_invoke_all('entity_delete', $account, 'user');
|
||||||
|
@ -2377,7 +2379,12 @@ function user_delete_multiple(array $uids) {
|
||||||
db_delete('authmap')
|
db_delete('authmap')
|
||||||
->condition('uid', $uids, 'IN')
|
->condition('uid', $uids, 'IN')
|
||||||
->execute();
|
->execute();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
watchdog_exception('user', $e);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
entity_get_controller('user')->resetCache();
|
entity_get_controller('user')->resetCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue