Domain config overrides use site default language when HTTP stack middleware is used

Created on 25 July 2024, 4 months ago

Drupal Version

10.3.1

Domain module version

2.0.0-beta1

Expected Behavior

When using custom HTTP stack middleware, which has a dependency on a service that depends on the config.factory service, overridden configuration objects should be for the current request language.

Actual Behavior

The site default language is cached within DomainConfigOverrider and used for all overridden configurations.

Steps to reproduce

1. Set up domain-enabled configuration with multiple translations. See #3451681 🐛 Configuration translation uses default language on domain-enabled config forms Active for full instructions using the External Link module.
2. Create a custom module which implements HTTP stack middleware that has the domain.negotiator service as a constructor argument.
3. Visit a page which should use the translated configuration. The site default language is used instead.

# my_module.services.yml
services:
  my_module.my_middleware:
    class: Drupal\my_module\MyMiddleware
    arguments:
      - '@domain.negotiator' # Example dependency which relies on configuration
    tags:
      - { name: http_middleware, priority: 190 }
🐛 Bug report
Status

Active

Version

2.0

Component

- Domain Config

Created by

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

Comments & Activities

  • Issue created by @nicross-com
  • Here is the quickest solution which involves asking the language manager for the current language each time an override is loaded. I'm sure there is a safer, more performant, and more robust solution out there. This just solved our immediate issue.

Production build 0.71.5 2024