From: mkanat%bugzilla.org <> Date: Sat, 24 Mar 2007 05:10:01 +0000 (+0000) Subject: Bug 374012: Use transactions inside of Bugzilla::Object X-Git-Tag: bugzilla-3.1.2~266 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fce3b9626675493b2afb9ce09ab7e59aaea82317;p=thirdparty%2Fbugzilla.git Bug 374012: Use transactions inside of Bugzilla::Object Patch By Max Kanat-Alexander r=LpSolit, a=LpSolit --- diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 6775d47190..ee1be2f9fe 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -171,6 +171,8 @@ sub update { my $table = $self->DB_TABLE; my $id_field = $self->ID_FIELD; + $dbh->bz_start_transaction(); + my $old_self = $self->new($self->id); my (@update_columns, @values, %changes); @@ -199,6 +201,8 @@ sub update { $dbh->do("UPDATE $table SET $columns WHERE $id_field = ?", undef, @values, $self->id) if @values; + $dbh->bz_commit_transaction(); + return \%changes; } @@ -210,9 +214,13 @@ sub create { my ($class, $params) = @_; my $dbh = Bugzilla->dbh; + $dbh->bz_start_transaction(); $class->check_required_create_fields($params); my $field_values = $class->run_create_validators($params); - return $class->insert_create_data($field_values); + my $object = $class->insert_create_data($field_values); + $dbh->bz_commit_transaction(); + + return $object; } sub check_required_create_fields {