Problem/Motivation
Facing the following fatal error
In Container.php line 147:
Circular reference detected for service "language_manager", path: "language
_request_subscriber -> language_manager -> config.factory -> symfony_mailer
.config_override -> plugin.manager.email_builder -> entity_type.manager ->
string_translation -> string_translator.locale.lookup".
Steps to reproduce
Given that the
"Drupal Symfony Mailer"was installed
And configured in a multilingual Drupal 10 website
When the admin install or uninstall modules
Then the"Circular reference detected for service"fatal error shows up
Proposed resolution
Manage the Circular reference of services in other ways
Remaining tasks
- File an issue
- Patch/MR fix
- Test
- Review
User interface changes
- N/A
API changes
- N/A
Data model changes
- N/A
Issue fork symfony_mailer-3370109
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 #2
rajab natshahComment #3
mytungsten commentedWe are experiencing the same issue with a multilingual site on Drupal 10.
Circular reference detected for service "language_manager", path: "language_request_subscriber -> language_manager -> config.factory -> symfony_mailer.config_override -> plugin.manager.email_builder -> entity_type.manager -> string_translation -> string_translator.locale.lookup"Comment #4
weseze commentedI have the same problem on a fresh install for Drupal 9.5.
Marking as major since we can no longer install this module.
Comment #5
rajab natshahComment #6
tichris59 commentedSame problem here with a multilingual site in drupal 10.0.9 when I enabled the module.
Comment #7
adambraun commentedrolling back to 2479bcc8 resolved it for me. Looks like the fixes for https://www.drupal.org/project/symfony_mailer/issues/3367047 caused the issue
Comment #8
nonom commentedThe issue persists in Drupal 10.1.0 for a multilingual profile installation.
Comment #9
rajab natshahYes, you are right, Martinez
Comment #10
rajab natshahComment #11
adamps commentedAs far as I can see, the only part of the loop that we can break is this:
symfony_mailer.config_override -> plugin.manager.email_builderMailerConfigOverride could fetch the email builder manager to a local variable inside
buildCache().I'm not able to test this as I don't have any multilingual sites, so I hope someone else can help.
Comment #12
rajab natshahComment #13
rajab natshahComment #14
rajab natshahTested:
Only for Drupal 10 and Interface Translation + Language + Configuration Translation + Content Translation
And only when having two or more languages.
Not having the issue in Drupal 9
Comment #15
metallized commentedI tried to remove the
plugin.manager.email_builderargument fromsymfony_mailer.config_overrideservice, but the problem is that creating manually a instance ofEmailBuilderManagerneeds aentityTypeManagerInterfaceargument, so now the circular reference is here, i think we must remove theEntityTypeManagerInterfacefromEmailBuilderManager.phpon line72.What i unsderstand is that the
localerequiresentity_type.managerto load translated configs and this modules try to override those configs, requiring the same dependencyentity_type.managerso the circular reference happens.Don't know if is this correct, please review and let know how can i help you to make a fix, i am using
Drupal 10andlocalemodule.Comment #16
rajab natshahIs the following issue related?
#3355846: Circular reference on multi-language sites
Comment #17
kreatil commentedSame or similar issue here after updating to 1.3.0-rc1 on Drupal 9.5.10 and PHP 8.1.16
Circular reference detected for service "entity_type.manager", path: "scheduler.manager -> date.formatter -> entity_type.manager -> string_translation -> string_translator.locale.lookup -> config.factory -> symfony_mailer.config_override -> plugin.manager.email_builder".It took me four hours to figure this out, because at first I assumed the error was caused by scheduler. Now I can definitely break it down to the update from symfony_mailer-1.3.0-beta2 to symfony_mailer-1.3.0-rc1.
Comment #18
kreatil commentedThis is the error message that I get when I try to clear caches via admin ui:
Comment #19
kreatil commentedForwarding to dev-1.x 9b1509d does not solve it. Reverted to 1.3.0-beta2 to get rid of the issue.
Comment #20
anybodySame here! Happened when we uninstalled the "reroute" module, but that may be unrelated.
Comment #21
trickfun commentedI think this error prevent sending mail with webform.
I can send mail with symfony test but not with webform.
I downgrade to 1.2.1 and all works fine.
Thank you
Comment #23
metallized commentedI think this is a temporary fix, please tell me what else we can do.
Comment #24
adamps commented@metallized Many thanks it is the only possible fix I can see - not just temporary.
Please can you put the formatting back how it was in symfony_mailer.services.yml and I will commit it (arguments all on a single line and in single quotes - it's the same in core.services.xml).
Comment #25
metallized commentedDone, have you read my comments on #15, maybe if we remove the depency on
entity_type.managerinEmailBuilderManager:75we can fixed?Comment #26
metallized commentedComment #27
adamps commentedThanks for the updated patch. Key question: does this fix the bug? Please can people try it and report back?
EmailBuilderManager uses entity_type.manager - if we remove that we will break some things.
My idea with the current patch is MailerConfigOverride will only load EmailBuilderManager when
moduleHandler->isLoaded()is TRUE. For the very early calls to get config in middleware, the loading will be skipped. If it's still broken then we didn't wait long enough.Comment #28
adamps commentedI installed some language modules on a test site, then I could hit this bug. I applied the patch from #26 and the problem was fixed. So the patch seems good for me.
Comment #29
kreatil commentedI can confirm patch #25 fixes the error. Thank you @metallized
Comment #30
adamps commentedComment #32
adamps commentedGreat thanks everyone