summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-12-17 07:00:00 +0100
committerByron Jones <bjones@mozilla.com>2013-12-17 07:00:00 +0100
commit5c60944bdc3cf52369fadc523a2a4f303343ca12 (patch)
tree01e7310ab59d04e95f81056d9ada50bcbe9eb922 /Bugzilla
parent9ae8acb378094734fd000b82659350a3947ab413 (diff)
downloadbugzilla-5c60944bdc3cf52369fadc523a2a4f303343ca12.tar.gz
bugzilla-5c60944bdc3cf52369fadc523a2a4f303343ca12.tar.xz
Bug 815026: Bugzilla::Object cache should be cleared when an object is updated or removed from the database
r=dkl, a=sgreen
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Object.pm16
1 files changed, 15 insertions, 1 deletions
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index add5887a6..16b3a1ebb 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -173,11 +173,21 @@ sub _cache_set {
Bugzilla->request_cache->{$cache_key} = $object;
}
+sub _cache_remove {
+ my $class = shift;
+ my ($param) = @_;
+ $param->{cache} = 1;
+ my $cache_key = $class->cache_key($param)
+ || return;
+ delete Bugzilla->request_cache->{$cache_key};
+}
+
sub cache_key {
my $class = shift;
my ($param) = @_;
if (ref($param) && $param->{cache} && ($param->{id} || $param->{name})) {
- return $class . ',' . ($param->{id} || $param->{name});
+ $class = blessed($class) if blessed($class);
+ return $class . ',' . ($param->{id} || $param->{name});
} else {
return;
}
@@ -451,6 +461,8 @@ sub update {
$self->audit_log(\%changes) if $self->AUDIT_UPDATES;
$dbh->bz_commit_transaction();
+ $self->_cache_remove({ id => $self->id });
+ $self->_cache_remove({ name => $self->name }) if $self->name;
if (wantarray) {
return (\%changes, $old_self);
@@ -469,6 +481,8 @@ sub remove_from_db {
$self->audit_log(AUDIT_REMOVE) if $self->AUDIT_REMOVES;
$dbh->do("DELETE FROM $table WHERE $id_field = ?", undef, $self->id);
$dbh->bz_commit_transaction();
+ $self->_cache_remove({ id => $self->id });
+ $self->_cache_remove({ name => $self->name }) if $self->name;
undef $self;
}