Conflict with Symfony mailer results in Circular reference detected for service "current_user"

Created on 6 October 2023, about 1 year ago
Updated 18 December 2023, about 1 year ago

Problem/Motivation

When installing Symfony mailer and clearing cache, I see the following error

Circular reference detected for service "current_user", path: "asset.css.collection_optimizer -> asset.css.dumper -> file_system -> logger.channel.file -> current_user -> msqrole.manager".

I'm not sure exactly where the responsibility for the issue lies, with either MSQrole or Symfony mailer, but I was able to apply a workaround in this module.

Steps to reproduce

  1. Install the MSQRole module
  2. Install the Symfony mailer module
  3. Configure Symfony mailer to use inline css for email
  4. Clear cache in either site or using drush

Should be no error, but the error above appears in console, and uninstalling either MSQRole or Symfony mailer resolves the issue.

Proposed resolution

I was able to resolve this by modifying the way the msqrole.manager service called by msqroles version of current_user contructs its config object. As it sets up both $this->config = $config_factory->get('msqrole.settings') and $this->themeConfig = $config_factory->get('system.theme'); in the constructor, removing this and just using the configFactory and only getting the config and themeConfig from the factory when needed, this also resolves the issue. According to this article, this is also the better way of using config objects and its only used in the invalidateTags method.

Remaining tasks

Submit patch.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom andybroomfield

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

Comments & Activities

Production build 0.71.5 2024