merged fix for CRM-12404: 2f1fa6031c0952c51b16ee9d330bb0e21d30aa4b