Use Bugzilla::Object's remove_from_db when deleting a Component

RESOLVED FIXED in Bugzilla 4.4



7 years ago
7 years ago


(Reporter: edmundhyan, Assigned: edmundhyan)


Bugzilla 4.4
Bug Flags:
approval +



(1 attachment, 1 obsolete attachment)



7 years ago
If I'm not mistaken there are no existing hooks that are triggered when a component is deleted.  I feel that there are 2 solutions to this:

1. Make Component::remove_from_db() call Object:remove_from_db() and thus make using the 'object_before_delete' hook possible
2. Add a hook before the database queries in Component::remove_from_db called 'component_before_delete'

I am not sure which method is preferred by you guys.  Let me know and I'd be more than happy to write a patch.

Comment 1

7 years ago
Our goal is to use Bugzilla::Object as much as possible, which we already did in bug 339380 for other Bugzilla::Component methods. So we will follow your suggestion #1.

Comment 2

7 years ago
the remove_from_db() on Product is also missing a call to the Object's method.  Should I file a separate bug for that or can I just use this one?

Comment 3

7 years ago
We have a bug for using remove_from_db everywhere--either make this a blocker or find an already-filed bug for adding the right remove_from_db method.

I would do each one separately unless the patches are 3 or 4 lines per object.
Assignee: extensions → edmundhyan


7 years ago
Severity: normal → enhancement
Ever confirmed: true
OS: Linux → All
Hardware: x86_64 → All
Summary: Adding a hook when deleting a component → Use Bugzilla::Object's remove_from_db when deleting a Component

Comment 4

7 years ago
Created attachment 551297 [details] [diff] [review]
Patch to to call Object's remove_from_db()

This patch is only for, will submit future patches on bug 641428.

Comment 5

7 years ago
Comment on attachment 551297 [details] [diff] [review]
Patch to to call Object's remove_from_db()

  Hey Edmund. Thanks for the patch! In the future, make sure to ask for review, so that your patch can get checked in. Here's a bit more about our process, if you'd like to know:

  So, the remove_from_db subroutine in Bugzilla::Component that you're editing was written before we had foreign keys. could you remove all the DELETE statements there and replace them all with just a call to SUPER::remove_from_db? The database will automatically handle all the other deletions.
Attachment #551297 - Flags: review-


7 years ago
Target Milestone: --- → Bugzilla 5.0

Comment 6

7 years ago
Created attachment 553390 [details] [diff] [review]
Patch v2

Revised patch and requested code review.
Attachment #551297 - Attachment is obsolete: true
Attachment #553390 - Flags: review?(mkanat)

Comment 7

7 years ago
Comment on attachment 553390 [details] [diff] [review]
Patch v2

Attachment #553390 - Flags: review?(mkanat) → review+


7 years ago
Flags: approval+

Comment 8

7 years ago
Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 7924.
Last Resolved: 7 years ago
Component: Extensions → Administration
Resolution: --- → FIXED


7 years ago
Blocks: 679516
You need to log in before you can comment on or make changes to this bug.