Refs #4921. Backport fix from CRM-12673.