From: Frédéric Buclin Date: Mon, 4 Nov 2013 18:55:45 +0000 (+0100) Subject: Bug 926952: Possible race conditions when editing or deleting a milestone or a version X-Git-Tag: bugzilla-4.4.2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36f7289d46a905f99aeb724cb65ab5ca3ae0fac0;p=thirdparty%2Fbugzilla.git Bug 926952: Possible race conditions when editing or deleting a milestone or a version r/a=glob --- diff --git a/Bugzilla/Milestone.pm b/Bugzilla/Milestone.pm index caa4afcdd4..b4ddaeafe6 100644 --- a/Bugzilla/Milestone.pm +++ b/Bugzilla/Milestone.pm @@ -97,10 +97,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 = ?', @@ -111,6 +113,8 @@ sub update { WHERE id = ? AND defaultmilestone = ?', undef, ($self->name, $self->product_id, $changes->{value}->[0])); } + $dbh->bz_commit_transaction(); + return $changes; } @@ -118,6 +122,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 }); @@ -146,8 +152,9 @@ sub remove_from_db { Bugzilla->user->id, $timestamp); } } - $self->SUPER::remove_from_db(); + + $dbh->bz_commit_transaction(); } ################################ diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm index 4a2c4a5e1d..7c341b6540 100644 --- a/Bugzilla/Version.pm +++ b/Bugzilla/Version.pm @@ -117,14 +117,18 @@ sub bug_count { sub update { my $self = shift; + my $dbh = Bugzilla->dbh; + + $dbh->bz_start_transaction(); my ($changes, $old_self) = $self->SUPER::update(@_); if (exists $changes->{value}) { - my $dbh = Bugzilla->dbh; $dbh->do('UPDATE bugs SET version = ? WHERE version = ? AND product_id = ?', undef, ($self->name, $old_self->name, $self->product_id)); } + $dbh->bz_commit_transaction(); + return $changes; }