I am having bother determining why the next code is not working in Drupal 7. _queue_processor
is a cron queue processor operate:
operate _queue_processor($uid) {
$transaction = db_transaction();
watchdog('debug', 'transaction created'); // This is not going to be referred to as.
attempt {
user_delete($uid);
}
catch (Exception $e) {
// An issue occurred. Rollback transaction.
$transaction->rollback();
throw $e;
}
// Rollback deliberately.
if (variable_get('some_var', FALSE)) {
$transaction->rollback();
}
}
The code by no means makes it previous the $transaction = db_transaction();
line. Nonetheless, if I take away the transaction and check out/catch, user_delete()
is named simply tremendous, and the transaction that user_delete_multiple()
creates inside itself works as effectively.
Is there one thing unsuitable with placing user_delete()
inside a transaction? I do know it already makes use of one, however I would like to have the ability to run the deletion after which conditionally rollback afterwards, and I would fairly not do that by throwing an exception in an implementation of hook_user_delete() to drive rollback.
I’m utilizing MariaDB.
Replace: I by no means figured it out, so I throw a customized exception within the hook and catch it.