Lack of interest Removal of dead groups during a User cache rebuild.


Well-known member
Oh what fun I have had tonight. Not sure if it was due to my import but I found that over 90% of my users had the wrong primary group set and they were not added to the "Registered" group (id 2).

So looking deep into the tables of XenForo I discovered that inside xf_user there is a user_group_id (the primary group id) and secondary_group_ids (a list of all the secondary groups). Much to my surprise nearly every user had ids in the secondary group that were not defined in XenForo. After many SQL queries to clean up the mess I now have a decent dataset but what I did find is that XenForo does not validate the ids against the list of known groups as defined in xf_user_group when rebuilding the user cache.

Please update the rebuildUserGroupRelations() function to validate and remove group ids that do not exist in both xf_user and xf_user_group_relation tables.