Fatal error: Unsupported operand types in /.../sites/all/modules/contrib/role_delegation/role_delegation.module on line 247
The problem is that single_user_role module has converted checkboxes => radios, and so the underlying data is stored as integers rather than arrays.

| Comment | File | Size | Author |
|---|---|---|---|
| #9 | single-user-role.png | 159.09 KB | mrpauldriver |
| #6 | 7.x-1.3-single_user_role-hook_user_presave-2375077-6.patch | 1.59 KB | IRuslan |
| #2 | single_user_role-hook_user_presave-2375077-2.patch | 1.5 KB | dalin |
| #1 | single_user_role-hook_user_presave-2375077-1.patch | 1.37 KB | dalin |
Comments
Comment #1
dalinComment #2
dalinHoly cats, that was terrible code, yet somehow still worked. Try again.
Comment #3
bessone commentedPatch #2 it's working for me.
Comment #4
IRuslan commentedFrom my point of view, the idea to use user_presave hook is wrong.
It's error-prone in many similar situations (i.e. #2646668: hook_user_presave).
Any validation of user_presave with order higher than module's one will get a fatal error.
My proposition is to move logic to change structure back into an array in the validate handler of form.
Tested patch with proof of concept in the attachment.
Comment #6
IRuslan commentedRe-roll patch with disabled testing - we have no tests for the module.
Comment #7
IRuslan commentedComment #8
upunkt commentedWhile not using the Role Delegation module as companion I was getting notices like
Notice: Undefined index: roles in single_user_role_user_presave() (line 81 ...and observing that assigned single user roles got discarded on calling user_presave() in a custom module. This phenomenon is described in https://www.drupal.org/node/2646668 also.
Looking at the code, I changed line 78 from
if (!is_array($edit['roles'])) {to
if (isset($edit['roles']) && !is_array(!empty($edit['roles']))) {and got it working for my usecase.
Still, I think IRuslan is right to move the logic. Consequently, his patch #6 does also work.
Comment #9
mrpauldriver commentedI am seeing as variation of this issue and the patch at #6 does not help.
I am seeing anomalies and errors on the user registration page. See screenshot
Comment #10
gbisht commented@MrPaulDriver your issue seems to be little different and will be handled separately in https://www.drupal.org/project/single_user_role/issues/3012822
Comment #12
gbisht commentedComment #13
gbisht commented