Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
e1642603
Commit
e1642603
authored
Oct 15, 2009
by
webchick
Browse files
#216098
by kwinters, jgoldberg, drawk, sun: Make drupal_goto() use the same parameters as url().
parent
c7557262
Changes
12
Hide whitespace changes
Inline
Side-by-side
includes/batch.inc
View file @
e1642603
...
...
@@ -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'
]))
)
;
}
}
}
...
...
includes/common.inc
View file @
e1642603
...
...
@@ -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
);
...
...
includes/form.inc
View file @
e1642603
...
...
@@ -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
{
...
...
modules/comment/comment.module
View file @
e1642603
...
...
@@ -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
);
...
...
modules/image/image.admin.inc
View file @
e1642603
...
...
@@ -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
{
...
...
modules/node/node.pages.inc
View file @
e1642603
...
...
@@ -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
)
)
;
}
...
...
modules/openid/openid.module
View file @
e1642603
...
...
@@ -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'
]);
...
...
modules/simpletest/tests/common_test.module
View file @
e1642603
...
...
@@ -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'
;
}
}
...
...
modules/simpletest/tests/session_test.module
View file @
e1642603
...
...
@@ -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
;
}
modules/system/system.api.php
View file @
e1642603
...
...
@@ -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
;
}
/**
...
...
modules/taxonomy/taxonomy.admin.inc
View file @
e1642603
...
...
@@ -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
;
...
...
modules/user/user.pages.inc
View file @
e1642603
...
...
@@ -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
)
)
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment