summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/batch.inc2
-rw-r--r--includes/common.inc32
-rw-r--r--includes/form.inc2
-rw-r--r--modules/comment/comment.module2
-rw-r--r--modules/image/image.admin.inc2
-rw-r--r--modules/node/node.pages.inc2
-rw-r--r--modules/openid/openid.module2
-rw-r--r--modules/simpletest/tests/common_test.module6
-rw-r--r--modules/simpletest/tests/session_test.module4
-rw-r--r--modules/system/system.api.php24
-rw-r--r--modules/taxonomy/taxonomy.admin.inc2
-rw-r--r--modules/user/user.pages.inc2
12 files changed, 40 insertions, 42 deletions
diff --git a/includes/batch.inc b/includes/batch.inc
index c0833208f..10fc2a737 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -447,7 +447,7 @@ function _batch_finished() {
$_SESSION['batch_form_state'] = $_batch['form_state'];
$function = $_batch['redirect_callback'];
if (function_exists($function)) {
- $function($_batch['source_url'], array('op' => 'finish', 'id' => $_batch['id']));
+ $function($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
}
}
}
diff --git a/includes/common.inc b/includes/common.inc
index 9bc5e335b..c3939b9cb 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -620,14 +620,13 @@ function drupal_encode_path($path) {
* Drupal will ensure that messages set by drupal_set_message() and other
* session data are written to the database before the user is redirected.
*
- * This function ends the request; use it instead of a return in your menu callback.
+ * This function ends the request; use it instead of a return in your menu
+ * callback.
*
* @param $path
* A Drupal path or a full URL.
- * @param $query
- * A query string component, if any.
- * @param $fragment
- * A destination fragment identifier (named anchor).
+ * @param $options
+ * An associative array of additional URL options to pass to url().
* @param $http_response_code
* Valid values for an actual "goto" as per RFC 2616 section 10.3 are:
* - 301 Moved Permanently (the recommended value for most redirects)
@@ -639,22 +638,25 @@ function drupal_encode_path($path) {
* - 307 Temporary Redirect (alternative to "503 Site Down for Maintenance")
* Note: Other values are defined by RFC 2616, but are rarely used and poorly
* supported.
+ *
* @see drupal_get_destination()
+ * @see url()
*/
-function drupal_goto($path = '', array $query = array(), $fragment = NULL, $http_response_code = 302) {
+function drupal_goto($path = '', array $options = array(), $http_response_code = 302) {
+ // A destination in $_GET always overrides the function arguments.
if (isset($_GET['destination'])) {
- extract(drupal_parse_url(urldecode($_GET['destination'])));
+ $destination = drupal_parse_url(urldecode($_GET['destination']));
+ $path = $destination['path'];
+ $options['query'] = $destination['query'];
+ $options['fragment'] = $destination['fragment'];
}
- $args = array(
- 'path' => &$path,
- 'query' => &$query,
- 'fragment' => &$fragment,
- 'http_response_code' => &$http_response_code,
- );
- drupal_alter('drupal_goto', $args);
+ drupal_alter('drupal_goto', $path, $options, $http_response_code);
+
+ // The 'Location' HTTP header must be absolute.
+ $options['absolute'] = TRUE;
- $url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE));
+ $url = url($path, $options);
header('Location: ' . $url, TRUE, $http_response_code);
diff --git a/includes/form.inc b/includes/form.inc
index 20b3230b9..207a48c0a 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -3065,7 +3065,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
$function = $batch['redirect_callback'];
if (function_exists($function)) {
- $function($batch['url'], array('op' => 'start', 'id' => $batch['id']));
+ $function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id'])));
}
}
else {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 073e4c74a..87ef24c0a 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -2092,7 +2092,7 @@ function comment_form_submit($form, &$form_state) {
$query['page'] = $page;
}
// Redirect to the newly posted comment.
- $redirect = array('node/' . $node->nid, $query, 'comment-' . $comment->cid);
+ $redirect = array('node/' . $node->nid, array('query' => $query, 'fragment' => 'comment-' . $comment->cid));
}
else {
watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc
index 5028279bb..e18422101 100644
--- a/modules/image/image.admin.inc
+++ b/modules/image/image.admin.inc
@@ -137,7 +137,7 @@ function image_style_form_add_submit($form, &$form_state) {
// Load the configuration form for this option.
if (isset($effect['form callback'])) {
$path = 'admin/config/media/image-styles/edit/' . $form_state['image_style']['name'] . '/add/' . $form_state['values']['new'];
- $form_state['redirect'] = array($path, array('weight' => $form_state['values']['weight']));
+ $form_state['redirect'] = array($path, array('query' => array('weight' => $form_state['values']['weight'])));
}
// If there's no form, immediately add the image effect.
else {
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index adb5f2da3..b9cedaeb1 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -302,7 +302,7 @@ function node_form_delete_submit($form, &$form_state) {
unset($_GET['destination']);
}
$node = $form['#node'];
- $form_state['redirect'] = array('node/' . $node->nid . '/delete', $destination);
+ $form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination));
}
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index d910e4dfa..f42c3db2a 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -448,7 +448,7 @@ function openid_authentication($response) {
// We'll want to redirect back to the same place.
$destination = drupal_get_destination();
unset($_GET['destination']);
- drupal_goto('user/register', $destination);
+ drupal_goto('user/register', array('query' => $destination));
}
else {
unset($form_state['values']['response']);
diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module
index 74866f098..8b6779463 100644
--- a/modules/simpletest/tests/common_test.module
+++ b/modules/simpletest/tests/common_test.module
@@ -63,9 +63,9 @@ function common_test_drupal_goto_land_fail() {
/**
* Implement hook_drupal_goto_alter().
*/
-function common_test_drupal_goto_alter(&$args) {
- if ($args['path'] == 'common-test/drupal_goto/fail') {
- $args['path'] = 'common-test/drupal_goto/redirect';
+function common_test_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+ if ($path == 'common-test/drupal_goto/fail') {
+ $path = 'common-test/drupal_goto/redirect';
}
}
diff --git a/modules/simpletest/tests/session_test.module b/modules/simpletest/tests/session_test.module
index d6c9914b2..01a9d3225 100644
--- a/modules/simpletest/tests/session_test.module
+++ b/modules/simpletest/tests/session_test.module
@@ -156,7 +156,7 @@ function session_test_form_user_login_alter(&$form) {
* Force the redirection to go to a non-secure page after being on a secure
* page through https.php.
*/
-function session_test_drupal_goto_alter(&$args) {
+function session_test_drupal_goto_alter(&$path, &$options, &$http_response_code) {
global $base_insecure_url;
- $args['path'] = $base_insecure_url . '/' . $args['path'];
+ $path = $base_insecure_url . '/' . $path;
}
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 8826e6a08..c1f597855 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -2262,21 +2262,17 @@ function hook_install_tasks() {
/**
* Change the page the user is sent to by drupal_goto().
*
- * @param $args
- * The array keys are the same as drupal_goto() arguments and the array can
- * be changed.
- * <code>
- * $args = array(
- * 'path' => &$path,
- * 'query' => &$query,
- * 'fragment' => &$fragment,
- * 'http_response_code' => &$http_response_code,
- * );
- * </code>
- */
-function hook_drupal_goto_alter(array $args) {
+ * @param &$path
+ * A Drupal path or a full URL.
+ * @param &$options
+ * An associative array of additional URL options to pass to url().
+ * @param &$http_response_code
+ * The HTTP status code to use for the redirection. See drupal_goto() for more
+ * information.
+ */
+function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) {
// A good addition to misery module.
- $args['http_response_code'] = 500;
+ $http_response_code = 500;
}
/**
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index c44fdeec1..7a12fbdc4 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -391,7 +391,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
'#type' => 'submit',
'#value' => t('Reset to alphabetical')
);
- $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('page' => $_GET['page']) : ''));
+ $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));
}
return $form;
diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc
index eef7d3f62..0f42729a2 100644
--- a/modules/user/user.pages.inc
+++ b/modules/user/user.pages.inc
@@ -294,7 +294,7 @@ function user_edit_cancel_submit($form, &$form_state) {
unset($_GET['destination']);
}
// Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
- $form_state['redirect'] = array("user/" . $form['#user']->uid . "/cancel", $destination);
+ $form_state['redirect'] = array("user/" . $form['#user']->uid . "/cancel", array('query' => $destination));
}
/**