Bug 1059946

Summary: SQL error when deleting a sub-component that has sub-components
Product: [Community] Bugzilla Reporter: Jason McDonald <jmcdonal>
Component: AdministrationAssignee: Simon Green <sgreen>
Status: CLOSED CURRENTRELEASE QA Contact: Matt Tyson 🤬 <mtyson>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.4CC: ebaak, jmcdonal, rjoost
Target Milestone: 4.4   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.4.2014 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-03 01:00:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 653316    
Bug Blocks:    

Description Jason McDonald 2014-01-31 03:08:04 UTC
Description of problem:
If attempting to delete a sub-component that has sub-components causes mysql to respond with a foreign key constraint error.

Presumably Bugzilla should either recursively delete the child sub-components first, or only present the Delete link for sub-components that have no children.

Version-Release number of selected component (if applicable):
4.4.1013

How reproducible:
Always

Steps to Reproduce:
1. Go to Administration->Components, choose a Product and click the "Add" link under the Sub-Components heading for a some component.
2. Create a sub-component A and then create a sub-component B with parent A.
3. Click the "Delete" link for sub-component A, and press the confirm button.

Actual results:
DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`bugs/rh_sub_components`, CONSTRAINT `fk_rh_sub_components_parent_id_rh_sub_components_id` FOREIGN KEY (`parent_id`) REFERENCES `rh_sub_components` (`id`) ON UPDATE CASCADE) [for Statement "DELETE FROM rh_sub_components WHERE id = ?"] at Bugzilla/Object.pm line 411

Expected results:
Entire tree below sub-component A is deleted successfully, or I only get the option to delete sub-components that have no children.

Additional info:
none

Comment 1 Simon Green 2014-01-31 03:21:58 UTC
only present the Delete link for sub-components that have no children <-- this.

I thought I had a check for this already,

Comment 4 Matt Tyson 🤬 2014-03-03 01:00:44 UTC
This change is now live. If there are any issues, do not reopen this bug.
Instead, you should create a new bug and reference this bug.