- Issue created by @pearls
I am also experiencing this same issue. In my case, I believe this is experiencing some kind of conflict with the commerce license module. After enabling both, I receive this error when I try to update existing user accounts, create new user accounts, or add items to the cart. My error in the white screen of death:
The website encountered an unexpected error. Try again later.
TypeError: administerusersbyrole_user_assign_role(): Argument #2 ($account) must be of type Drupal\Core\Session\AccountInterface, null given, called in /var/www/html/WEBSITE/web/modules/contrib/administerusersbyrole/src/Plugin/Action/ChangeUserRoleTrait.php on line 19 in administerusersbyrole_user_assign_role() (line 65 of modules/contrib/administerusersbyrole/administerusersbyrole.module).
I can provide the backtrace from the log if it will be helpful in resolving this issue.
- 🇨🇦Canada avo webworks Ottawa, Ontario, Canada
I have the same error.
when creating a new entity = user ECA is to set a role.
Error is the same as reported:
TypeError: administerusersbyrole_user_assign_role(): Argument #2 ($account) must be of type Drupal\Core\Session\AccountInterface, null given - 🇨🇦Canada avo webworks Ottawa, Ontario, Canada
To get around this issue in ECA don't use the Pre-configured Add role action but instead use the Entity: Set Field Value.
Method: Append when not full yet.
Field name: roles
Filed value: The machine name of your roleThis works well without error being thrown by this module.
I tried to use Role Delegation module instead of Administer Users by Role.
The Role Delegation module does not give an error with ECA when you need to assign a role, but somehow it prevents the ECA model from working.
Rules module is an alternative to ECA. It does not give an error when assigning role rules. But there too, sometimes the rule doesn't work and sometimes it does.I don't know what the problem is with Rules, I haven't looked into it deeply.Finally I stopped using administerusersbyrole and role delegation modules. Instead of taking advantage of both modules, I removed them to make ECA work properly, which I needed more on other sides.
- 🇬🇧United Kingdom adamps
Thanks for the report.
ChangeUserRoleTrait->access()
allows$account = NULL
but it callsadministerusersbyrole_user_assign_role()
which does not. So it should check for NULL, and then set the current user. @avo I tried #4. It works fine for administrator role.
But if a non-administrator role (with "AdministerUsers byRole" permission) changes anything on the user entity, the same problem occurs again.