]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 926952: Possible race conditions when editing or deleting a milestone or a version
authorFrédéric Buclin <LpSolit@gmail.com>
Mon, 4 Nov 2013 18:53:52 +0000 (19:53 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 4 Nov 2013 18:53:52 +0000 (19:53 +0100)
r/a=glob

Bugzilla/Milestone.pm
Bugzilla/Version.pm

index 4f262fd2ee9d0174994d85e60055ce9963ab05b5..6d6465e4d692481038db2eeeb74ca79c9ac3dbcd 100644 (file)
@@ -98,10 +98,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 = ?',
@@ -112,6 +114,8 @@ sub update {
                   WHERE id = ? AND defaultmilestone = ?',
                  undef, ($self->name, $self->product_id, $changes->{value}->[0]));
     }
+    $dbh->bz_commit_transaction();
+
     return $changes;
 }
 
@@ -119,6 +123,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 });
@@ -147,8 +153,9 @@ sub remove_from_db {
                              Bugzilla->user->id, $timestamp);
         }
     }
-
     $self->SUPER::remove_from_db();
+
+    $dbh->bz_commit_transaction();
 }
 
 ################################
index 317b73d959bff8414c04b42e789c7005183e51f3..1dcd2b141bd51ac3958d6af7c4c446ab2699b183 100644 (file)
@@ -118,14 +118,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;
 }