From 031fbab35ae7d26ac7fa4c25dcf282159bd58d1e Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 16 Dec 2015 20:11:50 -0800 Subject: [PATCH] Fix rollbacks calls properly here. Upon fixing the reference counter thing in the previous commit, this bug caused tests to fail. We have to _rollback() properly any time we've called _begin_work(), particularly before die()'ing after a _begin_work(). --- Supporters/lib/Supporters.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 3b66ef0..0206172 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -389,15 +389,17 @@ sub addRequestConfigurations($$$) { my $requestId = $self->addRequestType($requestType); - die "addRequestConfigurations: unable to create request configurations" - unless defined $requestType; + if (not defined $requestType) { + $self->_rollback(); + die "addRequestConfigurations: unable to create request configurations"; + } my %descriptions; my $sth = $self->dbh->prepare("INSERT INTO request_configuration(request_type_id, description) " . "VALUES(?, ?)"); foreach my $description (@{$descriptionListRef}) { if (defined $descriptions{$description}) { - $self->dbh->rollback(); + $self->_rollback(); die "addRequestConfigurations: attempt to create duplicate request_configuration \"$description\" for requestType, \"$requestType\""; } $sth->execute($requestId, $description);