summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-06-26 20:30:49 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-06-26 20:30:49 +0000
commita9749f8b72560ea3d8cb78bdd3252d024f375256 (patch)
tree5d6a08decb1be654cd2e638d9faa6f8d8aea4d01
parent2598d31ef86499a0a3408203d26cbf7e70ef3a86 (diff)
downloadbrdo-a9749f8b72560ea3d8cb78bdd3252d024f375256.tar.gz
brdo-a9749f8b72560ea3d8cb78bdd3252d024f375256.tar.bz2
#154224 by hunmonk: add destination argument to _drupal_delete(), instead of using drupal_goto() directly, so the callback cycle can complete
-rw-r--r--includes/common.inc10
-rw-r--r--modules/node/node.module18
2 files changed, 16 insertions, 12 deletions
diff --git a/includes/common.inc b/includes/common.inc
index a8e6a7da6..dd19078b8 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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;
}
diff --git a/modules/node/node.module b/modules/node/node.module
index ccc34ae98..892ed6f30 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -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");
- }
}
/**