From 3ff56a88eebef3699df7e524dea89be7b593337f Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 12 May 2014 13:49:53 +0800 Subject: Bug 992767: backport bug 987032 to bmo (allow memcached to cache bugzilla configuration information) --- Bugzilla/Milestone.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Bugzilla/Milestone.pm') diff --git a/Bugzilla/Milestone.pm b/Bugzilla/Milestone.pm index a5f3ed383..d8fcd79a5 100644 --- a/Bugzilla/Milestone.pm +++ b/Bugzilla/Milestone.pm @@ -108,10 +108,12 @@ sub run_create_validators { sub update { my $self = shift; + my $dbh = Bugzilla->dbh; + + $dbh->bz_start_transaction(); my $changes = $self->SUPER::update(@_); if (exists $changes->{value}) { - my $dbh = Bugzilla->dbh; # The milestone value is stored in the bugs table instead of its ID. $dbh->do('UPDATE bugs SET target_milestone = ? WHERE target_milestone = ? AND product_id = ?', @@ -121,8 +123,11 @@ sub update { $dbh->do('UPDATE products SET defaultmilestone = ? WHERE id = ? AND defaultmilestone = ?', undef, ($self->name, $self->product_id, $changes->{value}->[0])); - Bugzilla->memcached->clear({ table => 'produles', id => $self->product_id }); + Bugzilla->memcached->clear({ table => 'products', id => $self->product_id }); } + $dbh->bz_commit_transaction(); + Bugzilla->memcached->clear_config(); + return $changes; } @@ -130,6 +135,8 @@ sub remove_from_db { my $self = shift; my $dbh = Bugzilla->dbh; + $dbh->bz_start_transaction(); + # The default milestone cannot be deleted. if ($self->name eq $self->product->default_milestone) { ThrowUserError('milestone_is_default', { milestone => $self }); @@ -158,8 +165,9 @@ sub remove_from_db { Bugzilla->user->id, $timestamp); } } + $self->SUPER::remove_from_db(); - $dbh->do('DELETE FROM milestones WHERE id = ?', undef, $self->id); + $dbh->bz_commit_transaction(); } ################################ -- cgit v1.2.3-24-g4f1b