Deleting an institution which has user's registrations causes error

Bug #1314440 reported by Son Nguyen
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Son Nguyen
1.10
Fix Released
High
Son Nguyen
1.7
Fix Released
High
Robert Lyon
1.8
Fix Released
High
Robert Lyon
1.9
Fix Released
High
Robert Lyon

Bug Description

Version: master(1.10)
Platform: all

When deleting an institution which contains some registrations, I got the following error:

  [WAR] a6 (lib/errors.php:739) Failed to get a recordset: postgres7 error: [-1: ERROR: update or delete on table "institution" violates foreign key constraint "usrregi_ins_fk" on table "usr_registration"
DETAIL: Key (name)=(instone) is still referenced from table "usr_registration".] in adodb_throw(DELETE FROM "institution" WHERE "name" = ? , Array)
Command was: DELETE FROM "institution" WHERE "name" = ? and values was (instone)
Call stack (most recent first):
log_message("Failed to get a recordset: postgres7 error: [-1: E...", 8, true, true) at /home/sonn/code/mahara/master/htdocs/lib/errors.php:95
log_warn("Failed to get a recordset: postgres7 error: [-1: E...") at /home/sonn/code/mahara/master/htdocs/lib/errors.php:739
SQLException->__construct("Failed to get a recordset: postgres7 error: [-1: E...") at /home/sonn/code/mahara/master/htdocs/lib/dml.php:925
delete_records("institution", "name", "instone") at /home/sonn/code/mahara/master/htdocs/admin/users/institutions.php:162
delete_submit(object(Pieform), array(size 4)) at Unknown:0
call_user_func_array("delete_submit", array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:527
Pieform->__construct(array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:162
Pieform::process(array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 2)) at /home/sonn/code/mahara/master/htdocs/admin/users/institutions.php:185
[WAR] a6 (lib/dml.php:925) Failed to get a recordset: postgres7 error: [-1: ERROR: update or delete on table "institution" violates foreign key constraint "usrregi_ins_fk" on table "usr_registration"
DETAIL: Key (name)=(instone) is still referenced from table "usr_registration".] in adodb_throw(DELETE FROM "institution" WHERE "name" = ? , Array)
Command was: DELETE FROM "institution" WHERE "name" = ? and values was (instone)
Call stack (most recent first):
delete_records("institution", "name", "instone") at /home/sonn/code/mahara/master/htdocs/admin/users/institutions.php:162
delete_submit(object(Pieform), array(size 4)) at Unknown:0
call_user_func_array("delete_submit", array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:527
Pieform->__construct(array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:162
Pieform::process(array(size 2)) at /home/sonn/code/mahara/master/htdocs/lib/pieforms/pieform.php:71
pieform(array(size 2)) at /home/sonn/code/mahara/master/htdocs/admin/users/institutions.php:185

Son Nguyen (ngson2000)
Changed in mahara:
assignee: nobody → Son Nguyen (ngson2000)
status: New → In Progress
Revision history for this message
Son Nguyen (ngson2000) wrote :

the patch https://reviews.mahara.org/3306 also fixes other issues when deleting an institution:

    1. Remove all institution collections
    2. Remove all institution custom layouts
    3. Remove all institution registrations

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

Reviewed: https://reviews.mahara.org/3306
Committed: http://gitorious.org/mahara/mahara/commit/218b076b3e735f15e6afa8f28f08b1a00829974c
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 218b076b3e735f15e6afa8f28f08b1a00829974c
Author: Son Nguyen <email address hidden>
Date: Fri May 2 15:12:15 2014 +1200

Fix issues when deleting an institution. Bug 1314440

1. Remove all institution collections
2. Remove all institution custom layouts
3. Remove all institution registrations

Change-Id: I87a36e601571054305e2948d460c2bb670825ee6
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Robert Lyon (robertl-9) wrote :

This patch (or parts of it) will need to be backported to earlier branches as client customers on earlier versions have been confused/frustrated with the deletion of an institution not working.

Changed in mahara:
milestone: none → 1.10.0
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Should be okay to backport because it's a bug fix, not a feature.

Do we need to also add a one-time DB upgrade script to delete leftover data from institutions that were deleted before this bug fix came into effect?

Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Son Nguyen (ngson2000) wrote :

Hi Aaron,

Yes, it would be good to delete leftover data from deleted institutions.
I will push patch for it.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/3422

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.7_STABLE" branch: https://reviews.mahara.org/3548

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.8_STABLE" branch: https://reviews.mahara.org/3549

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.9_STABLE" branch: https://reviews.mahara.org/3550

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

Reviewed: https://reviews.mahara.org/3422
Committed: http://gitorious.org/mahara/mahara/commit/64141d43025c70151fd3b462468eeb6eddd8da3c
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 64141d43025c70151fd3b462468eeb6eddd8da3c
Author: Son Nguyen <email address hidden>
Date: Tue Jun 10 11:53:06 2014 +1200

Delete leftover data not associated to any institution (Bug 1314440)

Another patch for bug 1314440 makes it so that when you delete an
institution, this data gets deleted. This patch cleans up the data
for institutions that were deleted before that patch was merged.

Change-Id: I167001f444a3fd204b12610ca10274d6218d9f96
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "1.9_STABLE" branch: https://reviews.mahara.org/3551

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.8_STABLE" branch: https://reviews.mahara.org/3552

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "1.7_STABLE" branch: https://reviews.mahara.org/3553

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

Reviewed: https://reviews.mahara.org/3548
Committed: http://gitorious.org/mahara/mahara/commit/a925cb67239f55779c88506bb857ed042e81ca92
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.7_STABLE

commit a925cb67239f55779c88506bb857ed042e81ca92
Author: Son Nguyen <email address hidden>
Date: Fri May 2 15:12:15 2014 +1200

Fix issues when deleting an institution. Bug 1314440

1. Remove all institution collections
3. Remove all institution registrations

Change-Id: I87a36e601571054305e2948d460c2bb670825ee6
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/3553
Committed: http://gitorious.org/mahara/mahara/commit/5487a3fa1527eff5e49d7e513f745aa1e4de2373
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.7_STABLE

commit 5487a3fa1527eff5e49d7e513f745aa1e4de2373
Author: Son Nguyen <email address hidden>
Date: Tue Jun 10 11:53:06 2014 +1200

Delete leftover data not associated to any institution (Bug 1314440)

Another patch for bug 1314440 makes it so that when you delete an
institution, this data gets deleted. This patch cleans up the data
for institutions that were deleted before that patch was merged.

Change-Id: I167001f444a3fd204b12610ca10274d6218d9f96
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/3552
Committed: http://gitorious.org/mahara/mahara/commit/c46e8fee66da6515df8473d1f0a557fc978a5b88
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.8_STABLE

commit c46e8fee66da6515df8473d1f0a557fc978a5b88
Author: Son Nguyen <email address hidden>
Date: Tue Jun 10 11:53:06 2014 +1200

Delete leftover data not associated to any institution (Bug 1314440)

Another patch for bug 1314440 makes it so that when you delete an
institution, this data gets deleted. This patch cleans up the data
for institutions that were deleted before that patch was merged.

Change-Id: I167001f444a3fd204b12610ca10274d6218d9f96
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/3549
Committed: http://gitorious.org/mahara/mahara/commit/654f1ddfc3cbd578d084b590dbe83eb57b7f073c
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.8_STABLE

commit 654f1ddfc3cbd578d084b590dbe83eb57b7f073c
Author: Son Nguyen <email address hidden>
Date: Fri May 2 15:12:15 2014 +1200

Fix issues when deleting an institution. Bug 1314440

1. Remove all institution collections
2. Remove all institution custom layouts
3. Remove all institution registrations

Change-Id: I87a36e601571054305e2948d460c2bb670825ee6
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/3551
Committed: http://gitorious.org/mahara/mahara/commit/44e4a92992af464e4b085dc47b3ecf6a2c6e68a3
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.9_STABLE

commit 44e4a92992af464e4b085dc47b3ecf6a2c6e68a3
Author: Son Nguyen <email address hidden>
Date: Tue Jun 10 11:53:06 2014 +1200

Delete leftover data not associated to any institution (Bug 1314440)

Another patch for bug 1314440 makes it so that when you delete an
institution, this data gets deleted. This patch cleans up the data
for institutions that were deleted before that patch was merged.

Change-Id: I167001f444a3fd204b12610ca10274d6218d9f96
Signed-off-by: Son Nguyen <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/3550
Committed: http://gitorious.org/mahara/mahara/commit/66aa9038ac94f494cf148b2991bb3c923b47d1b5
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.9_STABLE

commit 66aa9038ac94f494cf148b2991bb3c923b47d1b5
Author: Son Nguyen <email address hidden>
Date: Fri May 2 15:12:15 2014 +1200

Fix issues when deleting an institution. Bug 1314440

1. Remove all institution collections
2. Remove all institution custom layouts
3. Remove all institution registrations

Change-Id: I87a36e601571054305e2948d460c2bb670825ee6
Signed-off-by: Son Nguyen <email address hidden>

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: 1.10.0 → none
Aaron Wells (u-aaronw)
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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