summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Attachment.pm
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2014-01-31 08:18:51 +0100
committerByron Jones <bjones@mozilla.com>2014-01-31 08:18:51 +0100
commitc5464b5bb7dfece2bad2b8af9eba4d9b6d07d778 (patch)
tree092c3a3ecb3152aba305c8ec4323056fc27865e2 /Bugzilla/Attachment.pm
parentcbd6506533f7370ba27c6928e887889627acb6b9 (diff)
downloadbugzilla-c5464b5bb7dfece2bad2b8af9eba4d9b6d07d778.tar.gz
bugzilla-c5464b5bb7dfece2bad2b8af9eba4d9b6d07d778.tar.xz
Bug 956233: enable USE_MEMCACHE on most objects
r=dkl, a=glob
Diffstat (limited to 'Bugzilla/Attachment.pm')
-rw-r--r--Bugzilla/Attachment.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index c0521c9b4..d0bd8e4c2 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -908,6 +908,9 @@ sub update {
$dbh->do('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?',
undef, ($timestamp, $self->bug_id));
$self->{modification_time} = $timestamp;
+ # because we updated the attachments table after SUPER::update(), we
+ # need to ensure the cache is flushed.
+ Bugzilla->memcached->clear({ table => 'attachments', id => $self->id });
}
return $changes;
@@ -932,7 +935,10 @@ sub remove_from_db {
my $dbh = Bugzilla->dbh;
$dbh->bz_start_transaction();
- $dbh->do('DELETE FROM flags WHERE attach_id = ?', undef, $self->id);
+ my @flag_ids = $dbh->selectrow_array(
+ 'SELECT id FROM flags WHERE attach_id = ?', undef, $self->id);
+ $dbh->do('DELETE FROM flags WHERE ' . $dbh->sql_in('id', \@flag_ids))
+ if @flag_ids;
$dbh->do('DELETE FROM attach_data WHERE id = ?', undef, $self->id);
$dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isobsolete = ?
WHERE attach_id = ?', undef, ('text/plain', 0, 1, $self->id));
@@ -942,6 +948,13 @@ sub remove_from_db {
if (-e $filename) {
unlink $filename or warn "Couldn't unlink $filename: $!";
}
+
+ # As we don't call SUPER->remove_from_db we need to manually clear
+ # memcached here.
+ Bugzilla->memcached->clear({ table => 'attachments', id => $self->id });
+ foreach my $flag_id (@flag_ids) {
+ Bugzilla->memcached->clear({ table => 'flags', id => $flag_id });
+ }
}
###############################