Fix domain links for config pages when using Domain Microsite

Created on 20 June 2025, 25 days ago

Problem/Motivation

Steps to reproduce

1. Install and enable the [Domain]( https://www.drupal.org/project/domain ) and [Domain Microsite]( https://www.drupal.org/project/domain_microsite ) modules.
2. Create a base domain (e.g. `cities.org`) and one or more microsites that:
- Have `is_domain_microsite` = 1
- Define a `base_path` like `/city/boston`
- Set `parent_domain_id` to the main domain
3. Use the `domain_config_pages` context plugin to create domain-aware configuration pages.
4. Navigate to the config page under a microsite (e.g., `/city/boston/admin/content/microsite-metadata?config_pages=3`)
5. Observe that:
- The links generated by `getLinks()` are incorrect
- Microsite links contain duplicated paths or invalid hostnames
- The base domain link may also be broken due to misapplied base paths

Proposed resolution

- Add logic to detect if a domain is a microsite using `is_domain_microsite`
- If so, load the parent domain using `parent_domain_id` and use its hostname and scheme
- Prepend the microsite’s own `base_path` to the cleaned current route + query
- Strip the current microsite’s `base_path` from the active route to avoid duplication
- Refactor `getLinks()` to delegate URL construction to a helper method

Remaining tasks

Test Patch

User interface changes

- None, except that generated config context links will now be correct across domains and microsites.

API changes

- None. This change is internal to the plugin class.

Data model changes

- None.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇲🇽Mexico jaimeah

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

Comments & Activities

Production build 0.71.5 2024