Closed Bug 679516 Opened 13 years ago Closed 13 years ago

Use Bugzilla::Object's remove_from_db when deleting any object

Categories

(Bugzilla :: Administration, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.4

People

(Reporter: edmundhyan, Assigned: edmundhyan)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Not all objects, when deleted, are using Bugzilla::Object's remove_from_db() method.  This is part of the goal to audit every deletion in Bugzilla, bug 641428.  In addition, this allows users to use the object_before_delete extension hook when any object is deleted.

Component.pm has already been fixed in bug 675366.  This bug deals with all other objects.
Let's fix them all at once, please. No need to file one bug per module.
Blocks: bz-object
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Depends on: 675366
Ever confirmed: true
Target Milestone: --- → Bugzilla 5.0
This patch fixes the remove_from_db() of the following:
Bugzilla::Products
Bugzilla::Field
Bugzilla::Milestone

There is one object left that is not fixed, and that is Bugzilla::Attachment.  Although it uses a method called remove_from_db(), it's somewhat of a misnomer.  The file is indeed deleted from the database, but a record is kept in the 'attachments' table and marked obsolete.
Attachment #553598 - Flags: review?(mkanat)
Attachment #553598 - Flags: review?(LpSolit)
After talking to LpSolit on irc I am adding the clean-up of Bugzilla::Status as part of one patch dealing with remove_from_db() in general.
Attachment #553598 - Attachment is obsolete: true
Attachment #553598 - Flags: review?(mkanat)
Attachment #553598 - Flags: review?(LpSolit)
Attachment #553605 - Flags: review?(LpSolit)
Comment on attachment 553605 [details] [diff] [review]
Patch for Products, Field, Milestone, and Status

>=== modified file 'Bugzilla/Status.pm'

>     my $id = $self->id;

$id is no longer in use.


>     $dbh->bz_start_transaction();
>     $self->SUPER::remove_from_db();
>     $dbh->bz_commit_transaction();

We don't need a transaction for this single line. Bugzilla::Object already does it for us. Just call remove_from_db.


Otherwise looks good.
Attachment #553605 - Flags: review?(LpSolit) → review-
Attachment #553605 - Attachment is obsolete: true
Attachment #553611 - Flags: review?(LpSolit)
Comment on attachment 553611 [details] [diff] [review]
Patch for Products, Field, Milestone, and Status

>=== modified file 'Bugzilla/Status.pm'

> sub remove_from_db {
>     my $self = shift;
>     my $dbh = Bugzilla->dbh;
>     $self->SUPER::remove_from_db();
>     delete Bugzilla->request_cache->{status_bug_state_open};
> }

$dbh is unused. No need to define it. This line should be removed on checkin. r=LpSolit
Attachment #553611 - Flags: review?(LpSolit) → review+
Assignee: administration → edmundhyan
Status: NEW → ASSIGNED
Flags: approval+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Field.pm
modified Bugzilla/Milestone.pm
modified Bugzilla/Product.pm
modified Bugzilla/Status.pm
Committed revision 7938.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: