--CRM-15758, added code to invoke pre and post hook