Redirect issues
japanitrat - November 25, 2008 - 21:53
| Project: | Redirect 403 to User Login |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
I just peeked over this module, since i am currently developing something similar. Now that i solved it, i want to share some.
As i can see for 6.x, this module utilizes its own redirect header statement. I suggest to use drupal_goto('path', drupal_get_destination()), since it will shutdown drupal's flow correctly. Also drupal_get_destination() includes other query-variables, not only the internal drupal-path, as well as messages that has been set before.
The mentioned recursive redirect loop can be avoided by checking the path against 'user' in arg(0).
| Attachment | Size |
|---|---|
| r4032login-6--1.patch | 1 KB |

#1
Redirect gets in infinite loop as anonymous user hitting node/add with i18n path prefixes.
#2
This version of the patch employs
drupal_get_destination(), but notdrupal_goto()or the check forarg(0) == 'user'. This enables the module to work with i18n language prefixes, and doesn't infinitely redirect.Without using
drupal_get_destination()while i18n path prefixes are enabled, the module redirects to, for exampleen/en/node/add. Note the double-occurrence of the language prefixen. This results in a 404 Page not found error.#3
committed to DRUPAL-6--1 and HEAD
@Bevan, your patch didn't conform to http://drupal.org/patch/create, but I used it anyway since it was so small.
#4
From Bevan:
@Bevan: it's your patch... roll it back?
#5
@Bevan: I added you to CVS so you can just fix it instead of having to roll patch. I ended up committing it to DRUPAL-5, DRUPAL-6--1, DRUPAL-7--1, and HEAD, so this makes quite a mess.
#6
Nevermind, I rolled it back. Is there still some underlying problem from the original issue submission that needs to be resolved?
#7
(#518534: Redirects to /r4032login instead of old path was marked duplicate.)
I haven't tested whether #518534: Redirects to /r4032login instead of old path is a result of this (#339120: Redirect issues) change or not. I'm merely wondering. I would expect that I would have noticed a bug as significant as this in developing the patch. Perhaps there are other or more obscure causes? Have you tested?
I don't have time to work on it this week, but will probalby get around to it sooner or later...
#8
It turns out
drupal_get_destination()is indeed the cuprit here. This needs rerolling. Possibly we should state on the project page that this module is not compatible with i18n path prefixes, in the meanwhile?#9
subscribe
#10
I think the cleanest way to fix this is to check for language prefixes in
$_GET['q']. But this would require quite a bit of fairly ugly code, and I couldn't find the code that does this already in Drupal to see if there is something re-usable.#11
i18n redirect still not working on 6.12, will it be fixed soon?
#12
Breakerandi; Patches welcome
#13
My profession is to report bugs, I can't do anymore for the community because I know nothing about php.. sorry..
#14
I don' t get what's the point of #4 as for me patch from #2 fixed the redirection problem with i18n.
@#1: anonymous user hitting node/add with i18n path prefixes doesn't effect an infinite loop on my site (maybe because there is content creation allowed for anonymous users?)
@#1: anonymous user hitting /admin gets redirected to user/login?destination=admin so for me everything seems to be fixed with this patch.
#15
I find this bug too... and I see only 1 way how to fix this issue.
idea is:
remove laguage prefix.
in the
r4032login.module
$destination = drupal_urlencode($_REQUEST['q']);
i suggest to rewrite like this:
$destination = removeLanguagePrefixFromDestination(drupal_urlencode($_REQUEST['q']));
and add new function:
function removeLanguagePrefixFromDestination($destination)
{
$elements = explode('/', $destination);
$prefix = $elements[0];
$languages = language_list();
foreach ($languages as $lang)
if(strcasecmp($prefix, $lang->language)==0)
return substr($destination, strlen($prefix)+1); // remove prefix with slash
return $destination;
}
and everything works fine
any thoughts about this solution are welcome )
-----------------------------------------------------------------------------------
patch #2 doesn't work in my case
#16
i'm sorry but in my previous message patch.patch was not correctly generated .I recommited it in this message.
#17
mike-l, Please see the Drupal coding standards. Among other things
removeLanguagePrefixFromDestination()should ber4032login_remove_language_prefix_from_destination().However I think there is a Drupal core API function for this – I think it's
arg()with no parameters, ordrupal_get_normal_path().