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
Issue fork msqrole-3409535
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 #3
smustgrave commentedNormally 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.
Comment #4
randalv commentedHi @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..
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.
Comment #5
smustgrave commentedRemoved token dependency.
Comment #6
smustgrave commentedNW
Comment #7
smustgrave commentedRemoved variable from RoleManager, initial quick testing seems to still be working.
Comment #8
papagrandeComment #9
papagrandeI 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....
Comment #10
smustgrave commentedIt applies cleanly to the dev branch, that can be seen in the MR. If you’re using a tagged version that may not apply.
Comment #11
papagrandeAh, 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.
Comment #13
randalv commentedSorry 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!