I reported it as a bug* that a module was using drupal_goto to redirect the user to an external URL because another module that implemented hook_alter_drupal_goto was expecting only internal paths. I had originally thought the latter was at fault until I read the manual for drupal_goto:

Sends the user to a different Drupal page.

This issues an on-site HTTP redirect.

drupal_goto does work fine for external URLs so long as any modules implementing hook_alter_drupal_goto correctly handle it, so if that is expected use I think the documentation should make it clearer, e.g.

Sends the user to a different Drupal page or external URL.

This issues an HTTP redirect.

*#2022229: Incorrect usage of drupal_goto()

#2 core-2038629-correct-drupal-goto-documentation-2.patch408 bytessambonner
PASSED: [[SimpleTest]]: [MySQL] 40,338 pass(es). View


jhodgdon’s picture

Issue tags:+Novice

Judging by the comments on the related issue, it does sound like we should change the documentation for drupal_goto().

Actually, the documentation for the first parameter in drupal_goto() in D7 says this:

 * @param $path
 *   (optional) A Drupal path or a full URL, which will be passed to url() to
 *   compute the redirect for the URL.

And the documentation for hook_drupal_goto_alter() also already says:

 * Change the page the user is sent to by drupal_goto().
 * @param $path
 *   A Drupal path or a full URL.

So it is just the first line of drupal_goto() that is incorrect. This is a 7.x issue only; the function has been removed in Drupal 8:

Sounds like a good Novice issue to fix the first line of drupal_goto() documentation...

sambonner’s picture

Status:Active» Needs review
408 bytes
PASSED: [[SimpleTest]]: [MySQL] 40,338 pass(es). View

Attaching a patch that corrects this error.

jhodgdon’s picture

Status:Needs review» Reviewed & tested by the community

Short and sweet, thanks! I'll get this committed shortly.

jhodgdon’s picture

Status:Reviewed & tested by the community» Fixed

Thanks again! Committed to 7.x.

Automatically closed -- issue fixed for 2 weeks with no activity.