Problem
The destination parameter created by r4032login includes a leading slash which causes the corresponding redirect to include an extra slash in the url path. Thus, if a user does not have permission to access "http://mysite.com/someurl" and attempts to access it, the r4032login module will add "destination=/someurl" to the post vars and upon login the user will actually be redirected to "http://mysite.com//someurl" (note the extra leading slash).
Expected Behavior
User should be redirected to "http://mysite.com/someurl" without the extra leading slash.
Possible Solution
I managed to fix this behavior on our site by replacing
return $destination;
with
return rtrim($destination, '/');
in the _r4032login_remove_language function. This seems to work for our site, but I haven't done extensive testing of this solution so your mileage my vary.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | r4032login-remove-leading-slash-1741698-1.patch | 681 bytes | David Lesieur |
Comments
Comment #1
David Lesieur commentedComment #2
David Lesieur commentedActually this has already been fixed in the dev version.
Comment #3
Sk8erPeter commentedNo, it has not been fixed. I just enabled 7.x-1.5+13-dev, and the redirection is STILL wrong when Drupal is in a subdirectory - and the correct redirection is one of the main tasks of this module.
The bug:
http://xyz.local/drupal/en/adminI'm not logged in, so I get the message "Access denied. You must login to view this page.", and I get the login form, which is OK.
BUT the URL looks like this:
http://xyz.local/drupal/en/user/login?destination=/drupal/en/adminThe destination equals to
/drupal/en/admin, which is NOT correct, because it should only bedestination=admin(I just tried it, and this WOULD work correctly).http://xyz.local/drupal/en//drupal/en/admin!! So
drupal/en/is doubled.Comment #4
David Lesieur commentedI also have tested the 7.x-1.5+13-dev version and the leading slash issue has been fixed. Could your problem be more related to #1735762: Redirection not working on multi-lang site with prefixes?
Comment #5
deekayen commentedDitto on #4.
Comment #6
Sk8erPeter commentedOK, and could you please explain why I was redirected to http://xyz.local/drupal/en//drupal/en/admin (see the double slash!) with 7.x-1.5+13-dev version then? You didn't even write you have tested it with having Drupal in a SUBDIRECTORY.
Comment #7
David Lesieur commentedThe dev version works fine in a subdirectory when the site does not uses language prefixes (that's the case I have tested).
#1735762: Redirection not working on multi-lang site with prefixes appears to be the better place to discuss the case of language prefix + subdirectory.
Comment #8
Sk8erPeter commentedI've already posted it there too.
"when the site does not uses language prefixes (that's the case I have tested)"
khmmm... And could you tell me why don't you test it with language prefixes enabled? I simply don't understand. A tons of sites work this way...
I find it interesting that you are absolutely convinced that the module works well, and you reject my point of view, when you don't even test it under one of the most frequently used circumstances...
Comment #9
David Lesieur commentedPlease read the top of the present page. That problem has been fixed.
I'm not denying the other problem that you have reported. I'm merely referring you (and others) to the proper page where to address it. It is counterproductive to discuss the same issue in multiple threads.
Comment #10
Sk8erPeter commentedI understand what you say, but you don't understand what I say. :)
So if the leading slash problem has been fixed, why am I redirected to
http://xyz.local/drupal/en//drupal/en/admin(see the double slash!!)? This question is this way related to the leading slash problem, too... :)Comment #11
David Lesieur commentedWhen I look at the code, what I see is that a different piece of logic is being used when a language prefix is present. That, and the fact that other cases with no language prefix have already been fixed, is why the language prefix looks to be the culprit, although the problem is a combination of having both a language prefix and a subdirectory, and that the end result is an unwanted slash and a failed redirection. Do we get an agreement? :-)
Comment #12
Sk8erPeter commentedUnfortunately I didn't have time to inspect the code yet, but I'm sure it's some kind of bad code usage, because Drupal offers many-many pre-built functions to get the correct destination links even working with language prefixes. I hope I can spend some time debugging this module next week.
And the bigger problem is that using a language prefix, and having Drupal in a subdirectory is a really frequently occurring circumstance, so the developers should have had to think about it. :)