make beforeDelete and afterDelete work with 5.4 php