Issue 6255 errors when you delete a role

Fixed the issue and pushed the code for review, please check it.