diff options
author | lpsolit%gmail.com <> | 2008-01-20 22:03:53 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2008-01-20 22:03:53 +0100 |
commit | ba956f07b4f06f82ff679d8475bbde2dda288e6d (patch) | |
tree | f8caa6eafc3235e9109322aa4f51f86870437edc /Bugzilla | |
parent | 2d59048f6fe2a4589b10f5e5f914e4b14204897e (diff) | |
download | bugzilla-ba956f07b4f06f82ff679d8475bbde2dda288e6d.tar.gz bugzilla-ba956f07b4f06f82ff679d8475bbde2dda288e6d.tar.xz |
Bug 413222: Implement $attachment->remove_from_db - Patch by Frédéric Buclin <LpSolit@gmail.com> a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Attachment.pm | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index dafdf70ad..954765f03 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -758,8 +758,6 @@ Params: C<$bug> - Bugzilla::Bug object - the bug for which to insert Returns: the ID of the new attachment. -=back - =cut sub insert_attachment_for_bug { @@ -932,4 +930,30 @@ sub insert_attachment_for_bug { return $attachment; } +=pod + +=item C<remove_from_db()> + +Description: removes an attachment from the DB. + +Params: none + +Returns: nothing + +=back + +=cut + +sub remove_from_db { + my $self = shift; + my $dbh = Bugzilla->dbh; + + $dbh->bz_start_transaction(); + $dbh->do('DELETE FROM flags WHERE attach_id = ?', undef, $self->id); + $dbh->do('DELETE FROM attach_data WHERE id = ?', undef, $self->id); + $dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isurl = ?, isobsolete = ? + WHERE attach_id = ?', undef, ('text/plain', 0, 0, 1, $self->id)); + $dbh->bz_commit_transaction(); +} + 1; |