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.
Follow-up from #1305378: Tokens should use $options['langcode'] and not need a language object.
Both tokens [user:one-time-login-url] and [user:cancel-url] from the user module are not localized. These both urls should be localized in the users prefered language.
Comments
Comment #1
webflo CreditAttribution: webflo commentedI am working on a patch.
Comment #2
Gábor HojtsyRelated: #1754208: Convert hook_mail() and hook_mail_alter() to langcode
Comment #3
Gábor HojtsyComment #4
webflo CreditAttribution: webflo commentedComment #5
attiks CreditAttribution: attiks commentedit is possible that a language gets disabled, so this will return FALSE
same potential problem as above
Comment #6
attiks CreditAttribution: attiks commentedtitle fixed
Comment #7
webflo CreditAttribution: webflo commentedIts not necessary to check for the return of language_load(). The url function checks for this already.
Comment #8
attiks CreditAttribution: attiks commentedgood job
Comment #9
webchickJust a couple of minor things:
Let's switch this to the "new Language" method like we have in http://drupal.org/node/1739994 so we don't create more clean-up to do.
"user's"
That's not quite a sentence. Do you mean "Generated URL of the user's preferred language"?
Same thing here.
Comment #10
Gábor HojtsyFixed all requested changes.
Comment #12
Gábor Hojtsyuse-ing the Language class helps :)
Comment #13
webchickLooks good to me!
Committed and pushed to 8.x. Thanks!
Comment #14
mr.baileysMarked #1253336: user_pass_reset_url() does not pass language to url() as duplicate.
Comment #15
mr.baileysReworked the patch from #12 for D7.
Comment #17
BladeduTested this patch. It works fine by me.
Comment #18
bachbach CreditAttribution: bachbach commented#15 seems to work for me to.
Comment #19
rvb CreditAttribution: rvb commented#15 seems to work for me on Drupal 7.26, 7.27 now 7.28
Comment #20
rvb CreditAttribution: rvb commentedany chance this will make it into core? What needs to happen to get into core? Can I help?
Comment #21
dcam CreditAttribution: dcam commentedYes. Saying "it seems to work for me" is not very useful to the committer. There are things you can do to improve the situation.
Comment #22
dcam CreditAttribution: dcam commentedComment #23
mgifford@dcam - this was already brought into Core in D8. One would hope that all of this rigor of #21 was done in D8, but there is no evidence of this.
4 people are saying the patch in 15 works for them in D7. Not that any of them have said that they are using this in production, but there's a reasonable chance.
It needed a re-roll, but people follow examples. If we haven't followed those steps in getting a patch in D8, we shouldn't expect people to follow the same steps to backport a solution we've already agreed to.
Comment #24
mgiffordSo to load this patch on SimplyTest.me
I think I would see it admin/config/people/accounts
But I'm not seeing any multilingual information on that page after adding Abkhazian to the default install.
Comment #25
rvb CreditAttribution: rvb commentedI use patch #15 in production since release 7.26. It is working fine.
Here is how you can reproduce the issue:
1/ You need a website with multiple languages enabled (For example default language is EN (english) and NL (dutch))
2/ Create an account for a new user and select a non-default language (NL in our case)
3/ The email sent out to the user will be in the correct language, but will have the tokens [user:one-time-login-url] and [user:cancel-url] with the default language, not the language of your user. Meaning that when a user verifies his email address he will be automaticually send to the website in the wrong language.
There is nothing in the UI configurations that will change or is worth a screenshot I think.
Comment #26
mgifford@rvb want to test the patch I rolled in #23 (or for that matter #15 if you want to try the original first) and apply it to the git Core repository? I can't mark my own patch RTBC, but you can.
Comment #27
SpadXIII CreditAttribution: SpadXIII commentedWhen checking this patch for drupal7, I noticed that 'language' => $language was removed from the options-array of the token_replace call. This triggered some warnings and after a bit of testing, I found that the site:url-login token (system module) is broken because of this. I attached a new patch with the language inserted in the $options-array again.
For drupal8, I have not tested this. But as that patch (already applied in d8) is quite similar, it might need a bit of testing.
Note: this site:login-url token is used in the mail sent to a newly created user.
Comment #28
mgiffordThanks for catching that @SpadXIII - interdiffs are always good, but..
This applies nicely. Bot likes it. Applying it to SimplyTest.me doesn't help though as it doesn't send the emails.
In testing this, it's also going to be important to configure the User interface text language detection here admin/config/regional/language/configure as by default it isn't set up.
[site:login-url] is on admin/config/people/accounts in the Vertical tabs: Welcome (new user created by administrator)
Comment #29
SpadXIII CreditAttribution: SpadXIII commentedRerolled the patch after the last update (7.35).
Only change is the addition of $account->uid in the user_pass_rehash calls.
Comment #30
mgifford@webflo last touched this 3 years ago so unassigning.
Comment #34
maxplus CreditAttribution: maxplus commentedHi,
thanks for this patch.
I patched the current Drupal 7.53 with patch #29 and now my password reset link had the right language prefix.
In a rule I'm using
print user_pass_reset_url($user);
and that works great now.I see this is committed to D8, will this also be committed to D7 ?
Comment #38
tangozulu CreditAttribution: tangozulu at Coldfront Labs Inc. commentedRegenerated the patch for Drupal 7.95
Comment #39
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedThe patch in #38 is wrong, as it removes code from this issues: #3306390: [D7] Changing email address should invalidate one-time login links, specifically the
$account->mail
parameters: