Groups containing collections with cover images cannot be deleted

Bug #1988005 reported by Fergus Whyte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
21.04
Fix Released
Medium
Unassigned
21.10
Fix Released
Medium
Unassigned
22.04
Fix Released
Medium
Unassigned
22.10
Fix Released
Medium
Fergus Whyte

Bug Description

Attempting to delete a Group containing one or more collections with cover images set cannot be deleted due to a foreign key relation between collection and artifact for the "coverimage".

Revision history for this message
Fergus Whyte (fergusw) wrote :

I have seen this in 21.04, potentially present in other versions.

Changed in mahara:
importance: Undecided → Medium
assignee: nobody → Fergus Whyte (fergusw)
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

This issue doesn't happen on a page with a cover image but only when the cover image is on a collection. The error message is the following:

[WAR] 7e (lib/errors.php:852) Failed to get a recordset: postgres9 error: [-1: ERROR: update or delete on table "artefact" violates foreign key constraint "coll_cov_fk" on table "collection"
DETAIL: Key (id)=(14) is still referenced from table "collection".] in EXECUTE("DELETE FROM "artefact" WHERE id IN (14)")Command was: DELETE FROM "artefact" WHERE id IN (14)
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
    log_warn("Failed to get a recordset: postgres9 error: [-1: E...") at /home/kristina/code/mahara/htdocs/lib/errors.php:852
    SQLException->__construct("Failed to get a recordset: postgres9 error: [-1: E...") at /home/kristina/code/mahara/htdocs/lib/dml.php:1154
    delete_records_sql("DELETE FROM "artefact" WHERE id IN (14)", null) at /home/kristina/code/mahara/htdocs/lib/dml.php:1063
    delete_records_select("artefact", "WHERE id IN (14)") at /home/kristina/code/mahara/htdocs/artefact/lib.php:871
    ArtefactType::_delete_dbrecords(array(size 1)) at /home/kristina/code/mahara/htdocs/artefact/lib.php:822
    ArtefactType::bulk_delete(array(size 1), true) at /home/kristina/code/mahara/htdocs/artefact/file/lib.php:1600
    ArtefactTypeFile::bulk_delete(array(size 1)) at /home/kristina/code/mahara/htdocs/artefact/file/lib.php:2584
    ArtefactTypeImage::bulk_delete(array(size 1)) at /home/kristina/code/mahara/htdocs/lib/mahara.php:1928
    call_static_method("ArtefactTypeImage", "bulk_delete", array(size 1)) at /home/kristina/code/mahara/htdocs/artefact/lib.php:796
    ArtefactType::delete_by_artefacttype(array(size 2)) at /home/kristina/code/mahara/htdocs/lib/group.php:1043
    group_delete(2) at /home/kristina/code/mahara/htdocs/group/delete.php:62
    deletegroup_submit(object(Pieform), array(size 2)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:577
    Pieform->__construct(array(size 5)) at /home/kristina/code/mahara/htdocs/lib/pieforms/pieform.php:173
    Pieform::process(array(size 5)) at /home/kristina/code/mahara/htdocs/lib/mahara.php:5757
    pieform(array(size 5)) at /home/kristina/code/mahara/htdocs/group/delete.php:42

Steps to replicate:

1. Set up a group.
2. Create a page.
3. Create a collection and add a cover image.
4. Delete the group.

Results:
- Expected: The group can be deleted.
- Actual: The above error message is displayed.

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

Reviewed: https://reviews.mahara.org/c/mahara/+/13120
Committed: https://git.mahara.org/mahara/mahara/commit/330c4711c14790193417c9f6071a2748d72c731e
Submitter: "Robert Lyon <email address hidden>"
Branch: main

commit 330c4711c14790193417c9f6071a2748d72c731e
Author: Fergus Whyte <email address hidden>
Date: Fri Aug 26 18:39:13 2022 +1200

Bug 1988005: lib/group.php Added collection deletion logic to group delete function.

Change-Id: If5ceb073e86b27bbc4a4987c9e0c824ff5894d45

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

Patch for "22.04_DEV" branch: https://reviews.mahara.org/c/mahara/+/13140

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

Patch for "21.10_DEV" branch: https://reviews.mahara.org/c/mahara/+/13141

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

Patch for "21.04_DEV" branch: https://reviews.mahara.org/c/mahara/+/13142

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

Reviewed: https://reviews.mahara.org/c/mahara/+/13142
Committed: https://git.mahara.org/mahara/mahara/commit/68a9e8d5363eb52abf26e419b40f72cc63869591
Submitter: "Robert Lyon <email address hidden>"
Branch: 21.04_DEV

commit 68a9e8d5363eb52abf26e419b40f72cc63869591
Author: Fergus Whyte <email address hidden>
Date: Fri Aug 26 18:39:13 2022 +1200

Bug 1988005: lib/group.php Added collection deletion logic to group delete function.

Change-Id: If5ceb073e86b27bbc4a4987c9e0c824ff5894d45
(cherry picked from commit 330c4711c14790193417c9f6071a2748d72c731e)

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

Reviewed: https://reviews.mahara.org/c/mahara/+/13141
Committed: https://git.mahara.org/mahara/mahara/commit/9dea0115352baea3b317bc46b9c695365bb078a8
Submitter: "Robert Lyon <email address hidden>"
Branch: 21.10_DEV

commit 9dea0115352baea3b317bc46b9c695365bb078a8
Author: Fergus Whyte <email address hidden>
Date: Fri Aug 26 18:39:13 2022 +1200

Bug 1988005: lib/group.php Added collection deletion logic to group delete function.

Change-Id: If5ceb073e86b27bbc4a4987c9e0c824ff5894d45
(cherry picked from commit 330c4711c14790193417c9f6071a2748d72c731e)

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

Reviewed: https://reviews.mahara.org/c/mahara/+/13140
Committed: https://git.mahara.org/mahara/mahara/commit/b12b25d06b344a39c5e6a85145c1c0024797f495
Submitter: "Robert Lyon <email address hidden>"
Branch: 22.04_DEV

commit b12b25d06b344a39c5e6a85145c1c0024797f495
Author: Fergus Whyte <email address hidden>
Date: Fri Aug 26 18:39:13 2022 +1200

Bug 1988005: lib/group.php Added collection deletion logic to group delete function.

Change-Id: If5ceb073e86b27bbc4a4987c9e0c824ff5894d45
(cherry picked from commit 330c4711c14790193417c9f6071a2748d72c731e)

no longer affects: mahara
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.