[development] drupal_goto an external destination

Moshe Weitzman weitzman at tejasa.com
Tue May 6 13:56:59 UTC 2008

That code makes it clear that external urls are simply not supported,
and probably were never considered. I agree it woud be useful. Patches
welcome :)

On Tue, May 6, 2008 at 3:49 AM, Dave Cohen <drupal at dave-cohen.com> wrote:
> I need to send the user to an external URL after a form submit.  My approach
>  is to set $form['destination'] via hook_form_alter.  When the form is
>  submitted, drupal_goto is called.  In drupal_goto, my destination gets badly
>  munged and the user is sent to the wrong URL.
>  In my case, I'm trying to send the user to
>  http://apps.facebook.com/my_application/my_path.  But the user gets sent
>  instead to http://my_domain.com/drupal/%252Fmy_application/my_path.
>  The reason for this is at the start of drupal_goto.  It looks like this:
>   if (isset($_REQUEST['destination'])) {
>     extract(parse_url(urldecode($_REQUEST['destination'])));
>   }
>   else if (isset($_REQUEST['edit']['destination'])) {
>     extract(parse_url(urldecode($_REQUEST['edit']['destination'])));
>   }
>   $url = url($path, $query, $fragment, TRUE);
>  The use of extract() makes the code nearly impossible to understand, unless
>  you find perl intuitive, but I digress...
>  During extract() $path, $query, and $fragment all get set.  So does $scheme,
>  $host, $user and $pass.  But drupal_goto does nothing with the latter
>  variables, and in my case important parts of the URL are dropped.
>  Is there even a reason why parse_url is used here?  Why not something closer
>  to:
>  if (isset($_REQUEST['destination']))
>    $url = url($_REQUEST['destination'])
>  else
>    ...
>  And is there a workaround for me without patching core?
>  Thanks,
>  -Dave

More information about the development mailing list