Conflict with AccountSwitcher service

Created on 1 April 2025, 4 days ago

Problem/Motivation

Drupal core provides an AccountSwitcher service, to quickly change the currently logged in user.
For example, Symfony Mailer uses this service to switch to the appropriate account that needs to receive the email that the module is preparing.

We ran into conflicts here in some scenarios.
For example:
An admin is viewing the site in Dutch, and performs an action that triggers a mail to be sent to specific other user.
That other user's preferred language is French, and is saved as such in their profile.
When Symfony Mailer temporarily switches accounts to the French user, the LanguageNegotiationUserAccountSaver kicks in, finds the current language as Dutch (because the admin is viewing the site in Dutch), and saves the preferred language of the French user to Dutch.

Steps to reproduce

See example above.

Proposed resolution

AccountSwitcher changes a flag in the WriteSafeSessionHandler service. Use this to check if user language can be updated or not.

Remaining tasks

Create MR with fix

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium svendecabooter Gent

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024