The current drupal_get_destination() function in common.inc doesn't pass queries in paths in its if statement when logging in.

I added a couple lines and appended .$path to get it to work (more detail at http://drupal.org/node/154626). m3avrck suggested I make an issue and submit a patch, so here's my first attempt at doing so. The patch is attached. Looking at the code now, the if/else statements are fairly similar, so I'm thinking there may be a better way at optimizing the code. I set this to 'patch (code needs work)' as per the 'Submitting patches' handbook page.

To sum it up, when a query is in a URL that an anonymous user clicks on and has to log in, the query remains in the URL through the log in process. Real life example: if a bookmarklet is set up, its queries are still passed to a form. Currently, unless the user is logged in, the queries are not passed.

This may be rather unique (and why I didn't think to contribute it as a patch), so I may be out of line here to suggest such a change, but I thought I'd give a shot.

CommentFileSizeAuthor
passquery.patch640 bytesbsuttis
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mlncn’s picture

Agaric subscribing. If we're following right, it may be relevant to 'viral registration'

smitty’s picture

I have the same problem when following the link 'http://www.mysite.com/user/login?destination=node/add/image&edit[myvar]=190' in Drupal 5.3.

After login the string '&edit[myvar]=190' gets deleted from the url, so that in fact I can upload an image but the information myvar=190 is lost.

I tried this patch. But in my case the function drupal_get_destination() never is called.

What else can I do?

Please help!

Pancho’s picture

Version: 6.x-dev » 7.x-dev

Moving feature requests to D7 queue. Sorry...

smitty’s picture

Are you sure this is a feature request? I would rather see it as a bug which should be fixed as of the 5.x release.

andreashaugstrup’s picture

Category: feature » bug

This is a bug, not a new feature. Due to this behaviour in drupal_get_destination() it is impossible to reliably link to any page that uses the query string and requires authentication.

This is most apparent when using bookmarklets because these often require that a use is logged in (to create a node using prepopulate module for example), but other links may randomly break as well, for example linking to the second page in a paged query (path: /node?page=1).

It is very hard to explain to users why their bookmarklets or links only work if they are logged in ahead of time and it's even worse because they receive no prior warning. When they click the bookmarklet it's too late -- they are just sent to a page that doesn't work with no explanation why.

So +1 for fixing as a bug.

smitty’s picture

Please have a look at: http://drupal.org/node/213218

jhodgdon’s picture

Title: Passing query in form action URL in common.inc -- drupal_get_destination() patch » drupal_get_destination() doesn't work with queries

It looks to me as though this issue and #213218: Edit-part gets lost, when redirecting after Login are duplicates of each other, and that this is a bug that really should be fixed in Drupal 7, and then the fix needs to be backported to Drupal 6. It was originally reported in Drupal 5 (sheesh!) and has been sitting around in the issue queue as a "support request" since then, although it is actually a bug.

That other issue specifically mentioned having problems with user registration, so it may be worth reading it too, although I am going to close it as a duplicate since this one at least has the start of a patch.

See also this forum post: http://drupal.org/node/154626

plach’s picture

drnikki’s picture

subhajitfriend’s picture

Version: 7.x-dev » 6.x-dev

if you are submitting from a form just attach this in your form and everyhing should work, i guess:
$form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.