WarningPointsChange::applyUserBan does not reliably log errors

Xon

Well-known member
Affected version
2.2.15
If you have a warning action which applies a ban with a limited expiry, and then another warning action which applies a ban with no expiry, and the first user ban fails to apply, this results in the following being logged:
Code:
LogicException: Attempted to set 'end_date' while a save was pending without forceSet

The original failure reason is lost as \XF::logException in applyUserBan is operating in the current transaction while the 2nd exception is caught by the error handler and logged after the transaction is aborted.

This is because getRelationOrDefault has created a new entity, which is still linked to the user, which has failed to save. Rather than try to allow the warning action to pseudo-apply, it would be best to abort the entire thing.
 
Top Bottom