Saving a new user who has no PbT associations (the "terms" field in their account is blank) produces the following exception:
Uncaught PHP Exception TypeError: "array_diff(): Argument #2 must be of type array, string given" at ...\modules\contrib\permissions_by_term\permissions_by_term.module line 312
Code in question is:
// Rebuild permissions for nodes if needed.
$origTerms = $form['access']['terms']['#default_value'] ?? [];
$newTerms = $form_state->getValue('terms'); <--- returns "", not an array
$changes = array_diff($origTerms, $newTerms) + array_diff($newTerms, $origTerms); <--- failure here
Patch follows
Comments
Comment #2
_randy commentedComment #3
pacproduct commentedFacing this too.
Patch in #2 does make it work.
I'm wondering if we could not test whether the variable is an array directly though, as that's what
array_diffis expecting. So we're sure it receives the right data type.Attached patch is a suggestion with this approach + Comment explaining what the problem is.
Comment #5
marcoliverThanks! I've tested your patches and committed the changes to dev. Will be included in the next release.