Fix the defects found by the 4.x beta audit
Fixes the defects found by the 4.x beta audit: https://www.drupal.org/project/domain/issues/3642166
Each fix comes with a kernel test that fails on 4.x and passes here. No public method or constructor changes, and no behaviour a working site relies on changes; the findings whose fix would are described in the follow-up issue https://www.drupal.org/project/domain/issues/3642167.
What changes
- Domain: the default domain stays (only moves when another becomes default, after validation; delete/disable/"make inactive default" refused by entity access, used by the list, the edit form, the inline route and the actions); no self-redirect;
http_responseinvalidated on negotiation changes; inactive-domain paths decided at request time on every route; domain access varies by the domains the user administers (newuser.domain_admincache context); cache contexts of tokens and variable-scheme links; hostname/port/prefix validation; list save only saves moved domains; debug block and nav block fixes. - Domain Access: bulk actions need edit access to the Domain Access field and only assign the domains its widget offers; node access, create access, views access (route check and views access plugins) and the bulk actions vary by the user's domains (new
user.domain_accesscache context), so users with the same domains share cached output and pages stay in the dynamic page cache; a bulk action checks its domains once; grant settings flag a rebuild; per-type permissions depend on their content type; docs describe "publish to any domain" as the grants apply it. - Domain Alias: the environment alias hostname is never saved into a domain record (restored once in
Domain::preSave());getDomain()works, so the assigned-domain alias permissions work; one alias lookup per hostname; alias changes clear the page cache; port check shared. - Domain Config family: the 2.x migration runs on sites without the language module (
domain_config_update_10004()for those that skipped it; the service moved to domain_config, old name aliased); renaming keeps per-language overrides; language override cacheability; Config UI disable/destination/inspect fixes. - Domain Content: the "Affiliated content" and "Affiliated editors" overviews vary by the user's domains and follow the domain, content and user lists, so another editor's list is never served and the counts stay current.
- Domain Source: the "Active domain" views filter varies by domain, with a post update for saved views.
Release notes
- Unticking "Default domain" on the default domain keeps it the default.
- The Domain Access bulk actions need access to the Domain Access field and only assign the domains its widget offers.
- Views using the "Active domain" source filter are saved again by a post update.
Tests
New kernel tests: DomainDefaultDomainTest, DomainInactiveDomainTest, DomainCacheabilityTest, DomainAccessIntegrityTest, DomainAliasIntegrityTest, DomainConfigUpgradeTest, DomainLanguageOverrideIntegrityTest, DomainSourceViewsFilterTest, DomainContentCacheabilityTest, plus new cases in DomainHostnameConstraintTest and DomainConfigInlineActionTest. DomainConsoleCommandsTest::testReassignDomainAdmins() covers the domain:delete reassignment, whose fix moved to #3642184 (already in 4.x), so it passes on 4.x.
CI
Rebased on 4.x after #3642184. Every lane is green, next major (Drupal 12, Drush 15) included.
Performance, measured against 4.x on the same codebase: no database query added in any measured scenario, page requests within noise, the alias lookup four times faster; the bulk action access check is about a third slower because of its new field and domain checks.
AI-Generated: Yes (Claude Code ran the audit and wrote the fixes, their tests and this description. I reviewed them, and each new test of a fix in this MR was confirmed to fail on 4.x and to pass with the change.)