Bulk deletion fails for users with personal messages with replies

Bug #916998 reported by Richard Mansfield
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Richard Mansfield

Bug Description

When a user is deleted, an attempt is made to delete all notification_internal_activity records for that user. This attempt can fail, because in the case of personal message threads, other rows in notification_internal_activity can point to the records we are trying to delete, resulting in a foreign key error.

This error occurs outside the db transaction in delete_user(), so usually this bug doesn't stop users from being deleted, it stops their internal notifications from being deleted. In bulk delete operations, all the calls to delete_user are wrapped in a transaction, so deletion fails.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/993
Committed: http://gitorious.org/mahara/mahara/commit/9bc9d15c2780e7b12f49595a482d65ed8cd76e53
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit 9bc9d15c2780e7b12f49595a482d65ed8cd76e53
Author: Richard Mansfield <email address hidden>
Date: Mon Jan 16 14:12:07 2012 +1300

    Fix sql error in bulk user deletion (bug #916998)

    When a user is deleted, deletion of notification_internal_activity
    records can fail with a foreign key error when another row in
    notification_internal_activity has a parent field pointing to one of
    the records we are trying to delete. This is fixed by setting the
    parent fields to null before deletion.

    The handle_event('deleteuser') call in delete_user is also moved
    inside the transaction, to ensure that deleted users will have their
    notifications deleted correctly. Other subscribers to the deleteuser
    event in core should be unaffected.

    Change-Id: Ibc0a695e986bb175a00441f02d3e40abf38cbcde
    Signed-off-by: Richard Mansfield <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Melissa Draper (melissa)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.