Commit a9749f8b authored by Gábor Hojtsy's avatar Gábor Hojtsy

#154224 by hunmonk: add destination argument to _drupal_delete(), instead of...

#154224 by hunmonk: add destination argument to _drupal_delete(), instead of using drupal_goto() directly, so the callback cycle can complete
parent 2598d31e
......@@ -2934,9 +2934,13 @@ function drupal_delete_confirm($confirm) {
/**
* Initiates the deletion of all constructed packages. Confirmation messages
* are bypassed, but abort messages are respected.
*
* @param $destination
* Optional. A destination to go to after all packages are executed.
* Can be either a Drupal path, or an array with the keys 'path', 'query', 'fragment'.
*/
function drupal_delete_execute() {
_drupal_delete('execute');
function drupal_delete_execute($destination = FALSE) {
_drupal_delete('execute', '', array('destination' => $destination));
}
/**
......@@ -3025,7 +3029,6 @@ function _drupal_delete($op, $id = '') {
$confirm = NULL;
$execute = NULL;
$destination = FALSE;
// Process additional arguments.
$all_args = func_get_args();
......@@ -3081,6 +3084,7 @@ function _drupal_delete($op, $id = '') {
// Execute all packages.
case 'execute':
$execute = TRUE;
$destination = $args['destination'];
break;
}
......
......@@ -1846,7 +1846,15 @@ function node_revision_delete($nid, $revision) {
drupal_delete_add_callback(array('node_revision_delete_post' => array($node, $revision)));
drupal_delete_add_query('DELETE FROM {node_revisions} WHERE vid = %d', $revision);
node_invoke_nodeapi($node, 'delete revision');
drupal_delete_execute();
// Back to revisions page if multiple revisions exist.
if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 2) {
$destination = "node/$node->nid/revisions";
}
else {
$destination = "node/$node->nid";
}
drupal_delete_execute($destination);
}
else {
drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));
......@@ -1864,14 +1872,6 @@ function node_revision_delete_post($node, $revision) {
drupal_set_message(t('Deleted %title revision %revision.', array('%title' => $node->title, '%revision' => $revision)));
watchdog('content', '@type: deleted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $revision));
if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 1) {
drupal_goto("node/$node->nid/revisions");
}
else {
drupal_goto("node/$node->nid");
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment