Circular reference detected

Created on 18 December 2023, 12 months ago
Updated 20 February 2024, 10 months ago

Problem/Motivation

After updating to 10.2 all drush commands have been running into

Circular reference detected for service "current_user", path: "current_user -> msqrole.manager -> token -> current_user".

Steps to reproduce

Setup a 10.2 environment
Try installing this module
See error.

Proposed resolution

Believe the problem is this module declares a service called current_user which core does too.

Change current_user to msqrole.current_user

Remaining tasks

Rview

User interface changes

NA

API changes

Service name change

Data model changes

NA

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States smustgrave

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

Merge Requests

Comments & Activities

  • Issue created by @smustgrave
  • Status changed to Needs review 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Normally would recommend deprecating this service but it doesn't install at all on 10.2 so if we REALLY wanted to deprecate. Would have to fix the current version to <=10.1 and deprecate the service, start a new branch with the service name changed.

  • Assigned to RandalV
  • Status changed to Needs work 12 months ago
  • πŸ‡§πŸ‡ͺBelgium RandalV

    Hi @smustgrave,

    Thank you for the report.

    Sadly, renaming the service would partly nullify this module's functionality.
    We need to override the account proxy object so the active roles are taken into account by anyone addressing the `current_user` service.

    If we didn't do this, calling \Drupal::service('current_user')->getRoles(); would just return the configured roles for that user rather than the roles selected in Msqrole.

    Currently, the token service is used in msqrole.manager to allow for tokens in the custom cache tags to be invalidated.
    Maybe this is not needed, the less services we can have msqrole.manager depend on, the less situations could lead to circular references.

    So essentially I see two possible solutions..

    1. Remove token dependency in the msqrole.manager service (and perhaps more if possible)
    2. Don't add the msqrole.manager service via the service arguments in the overridden `current_user` service

    I do not have the time right now, but I'll do some testing to see what works best performance wise etc, and will push a solution ASAP.

  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Removed token dependency.

  • Status changed to Needs work 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Removed variable from RoleManager, initial quick testing seems to still be working.

  • πŸ‡ΊπŸ‡ΈUnited States papagrande US West Coast
  • Status changed to Needs work 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States papagrande US West Coast

    I tried to apply the patch from MR!4 and it failed. I'm very confused because the patch I downloaded from Gitlab doesn't look the same as https://git.drupalcode.org/project/msqrole/-/merge_requests/4/diffs#note....

  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    It applies cleanly to the dev branch, that can be seen in the MR. If you’re using a tagged version that may not apply.

  • πŸ‡ΊπŸ‡ΈUnited States papagrande US West Coast

    Ah, thanks. I forgot about updating to the dev version.

    The patch applies and the error goes away. Beyond that, I don't know this module well enough to properly review the changes.

  • Issue was unassigned.
  • Status changed to Fixed 10 months ago
  • πŸ‡§πŸ‡ͺBelgium RandalV

    Sorry for the delayed response.

    Thanks for giving a good start on the merge request, I did have to alter some more stuff (removing the dependencies on token etc).

    I added a new tagged release (1.0.13) that should fix this!

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

Production build 0.71.5 2024