XF 2.1 UserGroupChange service and forceset?

Jaxel

Well-known member
I have a function in a repository that is getting activated during an entity _postSave().

Code:
$userGroupChange = \XF::service('XF:User\UserGroupChange');
$userGroupChange->addUserGroupChange($user->user_id, $unique_id, $groups);

The problem with this, is the following error:
LogicException: Attempted to set 'secondary_group_ids' while a save was pending without forceSet in src/XF/Mvc/Entity/Entity.php at line 575

How should I get around this?
 
Typing from mobile so I can’t give a complete example, but look into \XF::runLater.

It takes a lamda function which gets executed at the tail end of the request, so you should be free of writePending locks by then.
 
Top Bottom