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.
Comment | File | Size | Author |
---|---|---|---|
passquery.patch | 640 bytes | bsuttis | |
Comments
Comment #1
mlncn CreditAttribution: mlncn commentedAgaric subscribing. If we're following right, it may be relevant to 'viral registration'
Comment #2
smitty CreditAttribution: smitty commentedI 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!
Comment #3
PanchoMoving feature requests to D7 queue. Sorry...
Comment #4
smitty CreditAttribution: smitty commentedAre 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.
Comment #5
andreashaugstrup CreditAttribution: andreashaugstrup commentedThis 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.
Comment #6
smitty CreditAttribution: smitty commentedPlease have a look at: http://drupal.org/node/213218
Comment #9
jhodgdonIt 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
Comment #10
plachPossibly related issue: #1069514: URL parameters are not passed along when logging in from a 403 or 404 page.
Comment #11
drnikki CreditAttribution: drnikki commentedHere's a backport to Drupal6
http://drupal.org/node/1128624#comment-4352802
Comment #12
subhajitfriend CreditAttribution: subhajitfriend commentedif 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()));