Problem/Motivation
In UiHelperTrait::drupalLogin() we call user_pass_reset_url() to build a url for 'user.reset' route, and then append '/login?destination=user/' . $account->id().
This does not work if the url ends with a language suffix like '_en'.
We would end up with a url like '***/user/reset/552/***/_*****_en/login?destination=user/552'.
This is relevant for contrib modules that use core traits for testing.
Steps to reproduce
Create and enable a language negotiation plugin which appends a suffix like '_en' (or perhaps '/en') to the url.
Write a functional test with that module and plugin enabled.
Call ->drupalLogin() in that test.
Proposed resolution
Instead of calling user_pass_reset_url(), we build a url for 'user.reset.login', which already has the '/login' suffix.
Unfortunately there is no built-in function for that.
Given that user_pass_reset_url() is a legacy procedural function, and we will have to redesign that part of Drupal in a modern way, for now we should simply hard-code everything.
We might even refrain from adding a new method in UiHelperTrait, as this could nameclash with existing methods in contrib tests, and we might want to remove it again in the future. Instead, we just inline everything. Ugly but least disruptive.
We can backport this to as many branches as possible.
Testing: I just realized that I would need to write an entire language negotiation plugin just to test this.
This would be a lot of effort for little benefit.
Maybe people can just keep this as a patch for now.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3599305-9-UiHelperTrait-drupalLogin-language-suffix-10.6.x.patch | 1.57 KB | donquixote |
| #10 | 3599305-9-UiHelperTrait-drupalLogin-language-suffix-11.3.x.patch | 1.57 KB | donquixote |
Issue fork drupal-3599305
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
donquixote commentedI just notice, this only applies to older Drupal versions prior to #3581056: Introduce a OneTimeAuthentication service and deprecate user_pass_rehash.
Still we could fix it for those versions.
Comment #3
donquixote commented11.3.x is the latest which does not have the new OneTimeAuthentication service.
Comment #4
donquixote commentedComment #5
donquixote commentedComment #7
donquixote commentedTest fail seems a bit random.
Here is a patch for people to use.
Comment #8
donquixote commentedPatch for 10.6.x.
EDIT: a/ and b/ prefix missing in patch.
Going to fix later.
Comment #9
donquixote commentedPatch format should be fixed now.
Comment #10
donquixote commented