Current user missing from language negotiator outside of request context

Created on 2 September 2025, 17 days ago

Problem/Motivation

This came up in πŸ› Wrong language field labels after `drush cr` because of Drush language negotiation Needs work . Currently LanguageRequestSubscriber sets the current user on LanguageNegotiator. As far as I can tell there is no need for this indirection. And in fact this means that if you are not within the context of a request, but you do have a current user set that user language negotiation does not work.

This is one of those ones which can be a bug, a task or a feature request depending on how you look at it. Marking as bug as it helps πŸ› Wrong language field labels after `drush cr` because of Drush language negotiation Needs work , but also fine with re-classifying it differently.

Proposed resolution

Set the current user directly on the language negotiator.

Remaining tasks

User interface changes

-

Introduced terminology

-

API changes

LanguageNegotiator takes a new $currentUser constructor argument while LanguageRequestSubscriber no longer takes a $current_user constructor argument.

Data model changes

-

Release notes snippet

-

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

language system

Created by

πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

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

Merge Requests

Comments & Activities

  • Issue created by @tstoeckler
  • πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

    Adding note about PathProcessorLanguage to the issue summary.

  • πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

    Wrote a draft change record and a test. Let's see if anything breaks.

  • Pipeline finished with Failed
    17 days ago
    Total: 161s
    #588086
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Appears to have a phpstan failure

    Line core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
    ------ --------------------------------------------------------------------
    140 Class Drupal\language\HttpKernel\PathProcessorLanguage constructor
    invoked with 5 parameters, 4 required.
    πŸͺͺ arguments.count

    Not sure a good rule of thumb but do we think these interfaces could be pretty widely uses in translation contrib modules? Only mention if maybe we should wait till 13 to remove.

  • Pipeline finished with Failed
    17 days ago
    Total: 572s
    #588306
  • πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

    I don't really have any strong feelings regarding the deprecation but per the Drupal Code Search:

  • Pipeline finished with Failed
    17 days ago
    Total: 925s
    #588317
  • Pipeline finished with Canceled
    17 days ago
    Total: 132s
    #588398
  • Pipeline finished with Failed
    17 days ago
    Total: 419s
    #588404
  • πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany

    So those last failures were fun, we actually had tests that were relying on language negotiation not running in order to work. And due to the default configuration that's actually not too far fetched. Wrote a change notice to that end in case anyone encounters that same issue.

    Let's see if this is now finally green.

  • Pipeline finished with Success
    17 days ago
    Total: 650s
    #588420
  • πŸ‡©πŸ‡ͺGermany tstoeckler Essen, Germany
Production build 0.71.5 2024