Wrap addSupporter operations in transaction

All of the addSupporter must now succeed (including sub-operations like
addEmailAddress).

This causes one failing test to now pass:
   ok 55 - addSupporter: fails if email_address given but email cannot be inserted
This commit is contained in:
Bradley M. Kuhn 2015-12-14 17:30:44 -08:00
parent 74146a15c9
commit 6e10f76d5a

View file

@ -96,6 +96,7 @@ sub addSupporter ($$) {
if ($sp->{public_ack}) {
die "display_name required if public_ack requested" unless defined $sp->{display_name};
}
$this->_beginWork;
my $sth = $this->dbh->prepare(
"INSERT INTO supporter(ledger_entity_id, display_name, public_ack)" .
" values(?, ?, ?)");
@ -107,6 +108,7 @@ sub addSupporter ($$) {
$this->addEmailAddress($id, $sp->{email_address}, $sp->{email_address_type})
if defined $sp->{email_address};
$this->_commit;
return $id;
}
######################################################################