Issue #3592980: Scope the domain selection to the form (URL query) and document #config_target-only support

What this does

Implements both parts of #3592980.

1. Scope the selection to the form (URL query argument, not tempstore)

The selected domain now lives in a URL query argument (?config_domain=...) instead of a per-user PrivateTempStore:

  • DomainConfigSwitcher reads the selection from the current request (DomainConfigSwitcherInterface::QUERY_ARG); it depends on request_stack and no longer exposes setSelectedDomainId().
  • Switch redirects to the current form with the selection in the query. The GET reload discards unsaved edits and shows the selected domain's values, and the form's own POST keeps the query so Save still targets that domain.
  • The selection is dropped as soon as you navigate away, fixing the cross-form stickiness reported in #3592820: a choice on one config form no longer silently applies to every other config form.

This is the URL-based behaviour the reporter suggested. (The literal form-state-rebuild approach was discarded: on a rebuild Drupal repopulates fields from the submitted input, so the form would display the previous domain's values unless the input were wiped.)

2. Document the #config_target-only support

Only ConfigFormBase forms whose fields use the core #config_target API are supported. Forms that expose their config through getEditableConfigNames() - such as the Appearance (theme settings) form - read their configuration in buildForm(), before hook_form_alter() runs, so the switcher cannot retarget the displayed values and the selector is intentionally not shown on them. The README Limitations section now states this and names the Appearance form.

Tests

  • Kernel (DomainConfigSwitcherTest): selection resolved from the request query argument, including the permission and assignment guards.
  • Functional (DomainConfigSwitcherUiTest): a new test asserts the selection is carried in the URL and does not leak to another load of the form; the existing read/write-retargeting test still passes.

Verified locally: kernel 4 tests / 39 assertions; functional 3 tests / 29 assertions (Docker). PHPCS (Drupal,DrupalPractice) / PHPStan / CSpell clean.

Merge request reports

Loading