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.

Comments

David Lesieur’s picture

Status: Active » Needs review
StatusFileSize
new681 bytes
David Lesieur’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Needs review » Fixed

Actually this has already been fixed in the dev version.

Sk8erPeter’s picture

Priority: Normal » Critical
Status: Fixed » Active

No, 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:

  1. I have Drupal in a subdirectory called "drupal". The site is multilingual.
  2. I type the following:
    http://xyz.local/drupal/en/admin
    I'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/admin
    The destination equals to /drupal/en/admin, which is NOT correct, because it should only be destination=admin (I just tried it, and this WOULD work correctly).
  3. After that, the module redirects me to
    http://xyz.local/drupal/en//drupal/en/admin
    !! So drupal/en/ is doubled.
  4. Of course, I get a not found page:

    "The requested page "/drupal/en/drupal/en/admin" could not be found."

David Lesieur’s picture

I 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?

deekayen’s picture

Status: Active » Fixed

Ditto on #4.

Sk8erPeter’s picture

Status: Fixed » Active

OK, 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.

David Lesieur’s picture

Status: Active » Fixed

The 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.

Sk8erPeter’s picture

I'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...

David Lesieur’s picture

Please 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.

Sk8erPeter’s picture

I 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... :)

David Lesieur’s picture

When 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? :-)

Sk8erPeter’s picture

Unfortunately 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.

"the problem is a combination of having both a language prefix and a subdirectory"

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. :)

Status: Fixed » Closed (fixed)

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