Actions
Defect #16795
closedMember#destroy triggers after_destroy callbacks twice
Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
The callback 'after_destroy' for Member is called twice when deleting a member due to the following lines
https://github.com/redmine/redmine/blob/master/app/controllers/members_controller.rb:99
and
https://github.com/redmine/redmine/blob/master/app/models/member_role.rb:42
Files
Updated by Islam Azab over 10 years ago
https://github.com/redmine/redmine/blob/master/app/controllers/members_controller.rb
def destroy if request.delete? && @member.deletable? @member.destroy end respond_to do |format| format.html { redirect_to_settings_in_projects } format.js format.api { if @member.destroyed? render_api_ok else head :unprocessable_entity end } end end
https://github.com/redmine/redmine/blob/master/app/models/member_role.rb
def remove_member_if_empty if member.roles.empty? member.destroy end end
Updated by Jean-Philippe Lang over 10 years ago
- Subject changed from fixed member deletion to avoid dublicate after_destroy callbacks to Member#destroy triggers after_destroy callbacks twice
- Category set to Code cleanup/refactoring
- Status changed from New to Resolved
- Assignee set to Jean-Philippe Lang
- Target version set to 2.5.2
- Resolution set to Fixed
Fixed in r13140, thanks for pointing this out.
Actions