Bug fix

Line 232 has a typo:

unset($domains['source']);

This unsets the literal key 'source' instead of the variable $source. The intent is to remove the source domain from the access domains list to avoid duplicates (since it's added separately on line 235), but the typo means the source domain ends up in the URL list twice.

Simplification

Follow-up to #3575069. With the new priority chain (DomainSourcePathProcessor at 310, DomainPathOutboundProcessor at 305, core at 300), getContentUrls() can set $options['domain'] directly instead of going through domain_target_id.

The current code:

  1. Sets $options['domain_target_id'] with the domain ID
  2. DomainSourcePathProcessor loads the domain entity again, re-loads the node entity, does route matching, fires hook_domain_source_alter, then finally sets $options['domain']
  3. Branches on $processed to decide between using the generated URL directly vs. manually calling $domain->buildUrl()

With $options['domain'] set directly:

  1. DomainSourcePathProcessor short-circuits (it already checks isset($options['domain']))
  2. DomainPathOutboundProcessor aliases the path for the target domain
  3. DomainPathProcessor rewrites base_url
  4. All URLs are absolute — no need for the $processed branching or $domain->buildUrl() fallback

Issue fork domain-3575261

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review
Related issues: +#3574800: Allow Url objects to specify the Domain as an option

Bug fix

DomainAccessManager::getContentUrls() had a typo on line 232:

unset($domains['source']);

This unsets the literal key 'source' instead of the variable $source, causing the source domain to appear twice in the URL list.

Simplification

getContentUrls() now sets $options['domain'] directly instead of going through $options['domain_target_id']. This skips the expensive DomainSourcePathProcessor roundtrip (entity re-loading, route matching, hook invocation) since the domain entity is already loaded in the loop.

All URLs are now always absolute — the $processed branching and $domain->buildUrl() fallback are no longer needed, since DomainPathProcessor (priority 80) rewrites base_url when $options['domain'] is set.

Deprecation

$options['domain_target_id'] in DomainSourcePathProcessor is now deprecated. Callers should set $options['domain'] to a DomainInterface entity directly instead. The existing domain_target_id logic is preserved for backward compatibility and will be removed in domain:4.0.0.

  • mably committed 25a1279c on 3.x
    fix: #3575261 Fix bug and simplify DomainAccessManager::getContentUrls...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

idebr’s picture

Nice clean-up 👌

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.