Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The redirect
return $this->redirect('user.page', [], ['query' => drupal_get_destination()]);
in ubercart/uc_cart/src/Controller/CheckoutController.php on line 85 results in multiple redirections.
The correct redirect is
return $this->redirect('user.register', [], ['query' => drupal_get_destination()]);
Comment | File | Size | Author |
---|---|---|---|
#15 | redirect_2789977_3.patch | 907 bytes | keshavv |
| |||
#11 | redirect_2789977_2.patch | 907 bytes | keshavv |
#9 | redirect_2789977_1.patch | 923 bytes | keshavv |
| |||
#6 | Screen Capture on 2016-08-26 at 06-11-56.gif | 1.66 MB | mathiasgmeiner |
#6 | Screen Capture on 2016-08-26 at 06-08-54.gif | 1.78 MB | mathiasgmeiner |
Comments
Comment #2
mathiasgmeiner CreditAttribution: mathiasgmeiner commentedComment #3
TR CreditAttribution: TR commentedAnonymous users can be either users who are not logged in or they can be users who do not have an account on the site yet. user.register is the tab for creating new accounts, and we don't want that as the landing page for the redirect. Better would be user.login.
user.page, which we use now, is less specific than user.login but it does bring you to the same page.
Comment #4
mathiasgmeiner CreditAttribution: mathiasgmeiner commentedBut if the user is not logged in, this path results in multiple redirects and the browsers (Firefox in my case) throw an error.
Comment #5
TR CreditAttribution: TR commentedSorry I wasn't clear - I didn't mean we won't change it, but it really shouldn't be causing errors for you right now as it is - a redirect isn't really problem. user.page (/user) is always a valid route and should always bring you to the same page as user.login (/user/login) for an anonymous user. Throwing errors IS a problem, but I can't reproduce that in Firefox or Chrome - perhaps you're using some contributed module like logintoboggan that modifies the log in process?
Comment #6
mathiasgmeiner CreditAttribution: mathiasgmeiner commentedThanks for the clarification!
I have Email Registration installed, but uninstallation doesn't change the behaviour of the redirects.
With Email Registration:
With Email Registration:
It is the same thing in Chrome and Safari.
But you are absolutely right that
user.login
instead ofuser.register
, it's way more user friendly!Comment #7
TR CreditAttribution: TR commentedWhat happens if you try to visit /user on your site while you are anonymous?
Comment #8
mathiasgmeiner CreditAttribution: mathiasgmeiner commentedJust /user is ok, everything is fine. But with /user?destination=/cart/checkout the multiple redirects happen.
Comment #9
keshavv CreditAttribution: keshavv at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedSame problem is happened.
When checkout as anonymous . the page isn't redirect to login. I will test it when url is "/user" , then working fine .
but when the url is with query string 'base_url/user?destination=/root/cart/checkout' then it will not working . and URL like 'base_url/user/login?destination=/root/cart/checkout' will working fine.
So i think changing in ubercart/uc_cart/src/Controller/CheckoutController.php on line 85 results in multiple redirections.
return $this->redirect('user.register', [], ['query' => drupal_get_destination()]);
Will be Great!
Comment #10
keshavv CreditAttribution: keshavv at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #11
keshavv CreditAttribution: keshavv at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedHere is the revised tested patch
Comment #14
keshavv CreditAttribution: keshavv at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #15
keshavv CreditAttribution: keshavv at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #17
TR CreditAttribution: TR commentedTestbot is working again.
Comment #18
AporieAnother thing to investigate is when using pathauto changing the url for /user.
@mathiasgmeiner, Are you using pathauto to redirect the /user path ?
You can have a look here.
Comment #19
TR CreditAttribution: TR commented@Aporie: If you use the patch in #15, does that fix the issue for you?
Comment #20
mathiasgmeiner CreditAttribution: mathiasgmeiner commented@aporie: no, I'm not using pathauto for a /user redirect. But I have not tested this patch! Thanks for reminding!
Comment #22
TR CreditAttribution: TR commentedI don't believe this has anything to do with Pathauto.
Ubercart redirects from /cart/checkout to /user?destination=/cart/checkout so that when the login or registration is complete the customer will be taken back to /cart/checkout.
Apparently, for anonymous users, core Drupal tries to redirect /user?destination=/cart/checkout to /user/login, but in the process reads the destination key and figures that you really want to go back to /cart/checkout. Then Ubercart sends the customer back to /user?destination=/cart/checkout, etc., resulting in a redirect loop.
This must be something with how Drupal 8 and/or Symfony treat the destination key, because this works as intended in Drupal 7 even though the same redirection is happening in both Ubercart and Core.
Anyway, redirecting to user.login (/user/login) instead of user.page (/user) seems to fix the issue, so I committed #15.
Comment #23
AporieSorry for the delay,
Yeah I confirm that the patch fixed the issue.
Redirecting to user.login or user.register do the tricks.