Using PHP array_flip with additional_usergroups field

Tom McIntyre

Active member
I am trying to understand building usergroup filters for the contents of addons.

In particular, the use of array-flip after merging an array variable with the secondary_group_ids in the xf_users table.I have been studying an addon that uses that technique to effectively create an array all the user_id's that share a common usergroup. The result was a warning level error that did not seem to affect the results. Once I changed the error reporting for that script, everything seems to be fine.

In trying to better understand this, I looked at the fields and saw that the econdary_grop_ids field is varbinary(255) and its contents were being treated as a single element in the array data that was being flipped.The error report showed the content of the offending array as a number in the first element and several numbers separated by commas and enclosed in parentheses as the second element.

i think the intent of the code was to convert the varbinary field into an array and then merge that array with the account's usergroup id. Since all the accounts I am interested in share the same usergrou_id of 2 for registered user The whole function is probably not needed. There is no need to filter on a near universal value.

On the other hand I would like to understand the code. Has anyone run into this problem with secondary_grop_ids before?
 
Back
Top Bottom