Problem/Motivation
I encountered a fatal error during a deployment which originated from DecoratedUserRolesAccessPolicy::calculatePermissions(). The following code calls into UserRolesAccessPolicy::calculatePermissions():
if (!$account instanceof TokenAuthUserInterface) {
return $this->inner->calculatePermissions($account, $scope);
}
This will load user role entities, which triggers entity storage hooks, which triggers hook discovery, which results in a fatal error because the modules providing the hooks are not available in the middle of a container initialization.
Steps to reproduce
The exact conditions to trigger this error might be hard to reproduce. In my project it happened when I was uninstalling a custom module during a config import. Immediately after the uninstallation of the module, the DIC is being rebuilt, and this caused the following fatal error to be logged, aborting the deployment:
[notice] Synchronisierung von Erweiterungen: ekw_juicer deinstalliert.
In ClassResolver.php line 32:
Class "masquerade_entity_type_alter" does not exist.
When debugging the stack trace it was evident that the bug originates from the DecoratedUserRolesAccessPolicy::calculatePermissions() method which is called when the anonymous user permissions are being checked during the container rebuild.
Proposed resolution
Skip the calculation of the permissions during the config sync procedure.
Issue fork simple_oauth-3588717
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
pfrenssenComment #4
bojan_dev commentedLooks good to me, please check the phpstan error, then we can merge this.
Comment #5
pfrenssenSure! I will also set the phpstan job to fail if there is an error, so this is more obvious and cannot be ignored by the likes of me :)
Comment #7
bojan_dev commented