Closed (fixed)
Project:
Permissions by Term
Version:
3.1.37
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Jun 2025 at 07:46 UTC
Updated:
1 May 2026 at 07:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
abhishek_gupta1 commented@themisterprof , I have fixed the issue and created MR, please revie wit once
Comment #4
mbayeux commentedThe website encountered an unexpected error. Try again later.
TypeError: Unsupported operand types: array + int in permissions_by_term_user_form_submit() (line 354 of modules/contrib/permissions_by_term/permissions_by_term.module).
Comment #5
mbayeux commentedComment #6
vitaliyb98 commentedProvided fix isn't working
Comment #11
vitaliyb98 commentedSomething is wrong with GitLab during pushing to the fork (returns 500 error). Added a patch that fixed that error with array_diff.
Comment #12
baluertlComment #13
baluertlI've encountered multiple PHP warnings in this module while working on a Drupal 10.4 site with PHP 8.3. After investigating the various reports in this issue, I've prepared a combined patch that addresses all the related type errors and also includes a minor cleanup.
Issues fixed in this patch
Technical Analysis
The root cause is that when multi-select form fields have no selections, Drupal returns an empty string instead of an empty array. This causes type errors in two places:
#default_value validation (line 344) by @vitaliyb98
$tids validation (line 336)
#default_valuefrom form structure$tidsfrom$form_state->;getValue('terms')array_diff()argument type errorforeach()argument type warningisset() && is_array()double validation$tids = is_array($tids) ? $tids : [];Why both fixes are needed
Additional improvements
$newTermsvariable – now uses$tidsdirectly@filedocblock at the top of the fileThis patch has been tested on:
permissions_by_term3.1.37Scenarios tested:
All PHP warnings mentions by the other commenters above have been eliminated in these scenarios. I hope this helps others encountering the same issues.
Comment #14
vitaliyb98 commentedHi @baluertl, thanks for contributing! The code looks good, but it would be great to add tests for it.
Comment #15
vitaliyb98 commentedComment #17
vitaliyb98 commentedAdded changes from the patch into the MR, tested
LGTM
Comment #19
vitaliyb98 commented