Follow-up to #3575163. Move DomainSourcePathProcessor's outbound path processor priority from 90 to 310, so it runs before core's AliasPathProcessor (300) instead of after.

This allows domain_path (at priority 305) to alias the internal path for the target domain and set $options['alias'] = TRUE, preventing core from overwriting with the active-domain alias. The previous approach (priority 90, after core aliasing) required a wasteful reverse-resolve step and a hook_domain_source_alter implementation.

At priority 310, DomainSourcePathProcessor receives internal paths (/node/1) instead of aliases. This works because DomainSourceRouteMatcher does its own inbound processing internally, and allowedPath() also handles internal paths.

New priority chain:

Priority Processor Module What it does
310 DomainSourcePathProcessor domain_source Determines source domain, sets options['domain']
305 DomainPathOutboundProcessor domain_path Aliases for target domain, sets options['alias'] = TRUE
300 Core AliasPathProcessor path_alias Skipped when options['alias'] is TRUE
80 DomainPathProcessor domain Rewrites base_url to target domain

Issue fork domain-3575227

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

BC breaking changes

Medium

1. hook_domain_source_alter() no longer receives a rewritten $path

Previously, domain_path implemented hook_domain_source_alter() to swap the alias in $path for the target domain. Any other module implementing this hook that relied on $path already containing a domain-specific alias will no longer see that — the hook still fires (in DomainSourcePathProcessor), but $path is now the internal path (e.g. /node/1) since DomainSourcePathProcessor runs before core aliasing.

2. DomainSourcePathProcessor now receives internal paths, not aliases

At priority 310 (before core's AliasPathProcessor at 300), the $path argument passed to DomainSourcePathProcessor::processOutbound() is the internal system path (/node/1), not an alias (/my-page). Any code that:

  • Extends DomainSourcePathProcessor and inspects $path expecting an alias
  • Uses allowedPath() with alias patterns in domain_source.settings.excluded_paths

...will need to use internal paths instead. allowedPath() itself works fine with internal paths, but excluded path patterns must now match internal paths (e.g. /node/* instead of /my-alias).

Low

3. domain_path's hook_domain_source_alter() implementation removed

Modules that depended on domain_path_domain_source_alter() being invoked (e.g. to observe or further modify the path after domain_path's alias swap) will no longer see that hook fire. The aliasing is now handled entirely by DomainPathOutboundProcessor at priority 305.

4. DomainPathOutboundProcessor priority changed from 85 to 305

Any module that registered an outbound path processor with a priority between 86–304 expecting to run between DomainSourcePathProcessor (was 90) and core aliasing (300) may now run in a different relative order. Specifically, processors that expected to see $options['domain'] already set and the path already aliased will now see the internal path instead.

5. $options['alias'] = TRUE side effect

When DomainPathOutboundProcessor finds a domain-specific alias, it sets $options['alias'] = TRUE. Any processor running after priority 305 that checks this flag will see it set for cross-domain links (it wasn't set before).

mably’s picture

@idebr do you think we should merge this?

idebr’s picture

Status: Needs review » Reviewed & tested by the community

  • mably committed 1d239493 on 3.x
    task: #3575227 Move DomainSourcePathProcessor priority before core's...
mably’s picture

Status: Reviewed & tested by the community » 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.

mably’s picture

Status: Fixed » Closed (fixed)

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