Error appears when deleting Institution collections that have been auto-copied to members accounts
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Confirmed
|
Medium
|
Unassigned |
Bug Description
This happens in both MySQL and Postgres
To replicate:
1. Create an institution template collection (set to 'Current auto-copied template') with portfolio completion.
2. Create a new account and run the cron so that the portfolio is created in the new member's account.
3. As admin, try to delete the institution template collection.
Result
- SQL error messages on screen. There is a foreign key constraint with collection_
Expected:
- Perhaps there should be a warning to institution admins that the collection has been auto-copied before deleting it.
- I think we need to delete from the collection_template table where originaltemplate = $this->id, rather than where collection = $this->id (htdocs/
Kristina mentioned that a Behat test for this would be good, since we don't regularly come across this scenario.
description: | updated |
description: | updated |
I created a wishlist item for the special deletion warning, which is a good idea, at bug #1969701.
I confirmed the test instructions and got the problem as well on main.
The warning and stacktrace:
[WAR] 4d (lib/errors. php:853) Failed to get a recordset: postgres9 error: [-1: ERROR: update or delete on table "collection" violates foreign key constraint "colltemp_ori_fk" on table "collection_ template" template" .] in EXECUTE("DELETE FROM "collection" WHERE "id" = ? ")Command was: DELETE FROM "collection" WHERE "id" = ? and values was (0:1)
DETAIL: Key (id)=(1) is still referenced from table "collection_
Call stack (most recent first):
log_ message( "Failed to get a recordset: postgres9 error: [-1: E...", 8, true, true) at /home/kristina/ code/mahara/ htdocs/ lib/errors. php:89 warn("Failed to get a recordset: postgres9 error: [-1: E...") at /home/kristina/ code/mahara/ htdocs/ lib/errors. php:853 n->__construct( "Failed to get a recordset: postgres9 error: [-1: E...") at /home/kristina/ code/mahara/ htdocs/ lib/dml. php:1045 records( "collection" , "id", "1") at /home/kristina/ code/mahara/ htdocs/ lib/collection. php:326 >delete( true) at /home/kristina/ code/mahara/ htdocs/ collection/ delete. php:97 ction_submit( object( Pieform) , array(size 2)) at /home/kristina/ code/mahara/ htdocs/ lib/pieforms/ pieform. php:577 >__construct( array(size 3)) at /home/kristina/ code/mahara/ htdocs/ lib/pieforms/ pieform. php:173 :process( array(size 3)) at /home/kristina/ code/mahara/ htdocs/ lib/mahara. php:5754 array(size 3)) at /home/kristina/ code/mahara/ htdocs/ collection/ delete. php:77
log_
SQLExceptio
delete_
Collection-
deletecolle
Pieform-
Pieform:
pieform(