CRM-15242 - Resubmit PR #4103

This restores the work done in #4103, which was accidentally deleted during a rebase.