Problem/Motivation
DomainAliasHooks injects LoggerChannelFactoryInterface in its constructor. This creates a circular service dependency when any third-party logger module (jsonlog, raven, etc.) is enabled, because logger.factory is a service_collector that resolves ALL logger-tagged services during container compilation.
Error:
Circular reference detected for service "Drupal\Core\Logger\LoggerChannelFactoryInterface",
path: "plugin.cache_clearer -> plugin.manager.block -> logger.channel.default ->
Drupal\Core\Logger\LoggerChannelFactoryInterface -> logger.jsonlog ->
Drupal\domain_alias\Hook\DomainAliasHooks"
drush cr fails. drush updb works (different bootstrap path).
This is the same bug that was already fixed in #3549346 for DomainSourcePathProcessor, but DomainAliasHooks was missed.
Steps to reproduce
- Enable
domain,domain_alias, andjsonlog(orraven) modules - Run
drush cr - Circular reference error
Proposed resolution
Remove LoggerChannelFactoryInterface from DomainAliasHooks constructor and remove the two error log calls (lines 113 and 120).
This follows the same approach used in:
- #3549346 — same bug in
DomainSourcePathProcessor, already fixed by removing the logger dependency - Drupal core #2838474 — same pattern in
FileSystem, removed logger dependency entirely
The logger was only used for two edge-case error messages when alias lookup fails (wrong domain ID, missing path prefix match). These conditions are still detectable by visible symptoms — wrong domain served, broken alias resolution.
Remaining tasks
Review and merge the MR.
User interface changes
None.
API changes
DomainAliasHooks::__construct() signature changes — LoggerChannelFactoryInterface parameter removed.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| domain-alias-remove-logger-dependency.patch | 1.64 KB | ugolek |
Issue fork domain-3583279
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
Comment #4
mably commentedMR 354 introduces a lazy
DomainLoggerFactoryservice in the domain module that wrapsLoggerChannelFactoryInterface. Registered withlazy: trueindomain.services.yml, its proxy is resolved only at runtime (whenget()is called), not during container compilation — breaking the circular reference.DomainAliasHooksnow injectsDomainLoggerFactoryInterfaceinstead ofLoggerChannelFactoryInterface. Other domain submodules can reuse this service to avoid the same circular dependency.The first error log call (no prefix match) was removed as unreachable dead code. The second (orphaned alias pointing to a deleted domain) is kept via the lazy logger.
@ugolek Could you review and test MR 354 against your setup?
Comment #6
mably commentedComment #8
mably commentedWe merged the fix but wanted to note that we were unable to reproduce the circular reference locally (Drupal 11.3.5, PHP 8.5.3, jsonlog 4.1.0, domain_alias enabled).
Running
drush crwith the code reverted to before the fix completed without error. TheHookCollectorPassregisters hook classes as standalone autowired services — it does not add them as dependencies ofmodule_handleror any other service. So the intermediate chain fromlogger.jsonlogtoDomainAliasHooksin the error path remains unclear to us.We're keeping the fix since your stack trace seems valid and the lazy wrapper is harmless, but could you share your exact Drupal core version and PHP version? That would help us understand whether this is tied to a specific core version's container compilation behavior.
Comment #11
mably commentedThanks again for reporting this issue.
I’ve pushed a change to revert the previous modifications, as I wasn’t able to reproduce the problem described on my side.
That said, opening an issue is only the first step — it’s also important to follow up and engage with any questions or requests for clarification from maintainers. Without that feedback loop, it’s difficult to investigate further or move things forward.