Commit 05d7a631 authored by Markus Jylhänkangas's avatar Markus Jylhänkangas
Browse files

Update transactions to use Database methods

parent b86b53ce
...@@ -1547,7 +1547,7 @@ sub delete_list_member { ...@@ -1547,7 +1547,7 @@ sub delete_list_member {
my $total = 0; my $total = 0;
my $sdm = Sympa::DatabaseManager->instance; my $sdm = Sympa::DatabaseManager->instance;
$sdm->__dbh->begin_work; $sdm->begin;
foreach my $who (@u) { foreach my $who (@u) {
$who = Sympa::Tools::Text::canonic_email($who); $who = Sympa::Tools::Text::canonic_email($who);
...@@ -1602,13 +1602,12 @@ sub delete_list_member { ...@@ -1602,13 +1602,12 @@ sub delete_list_member {
$self->_cache_publish_expiry('member'); $self->_cache_publish_expiry('member');
delete_list_member_picture($self, shift(@u)); delete_list_member_picture($self, shift(@u));
unless ($sdm->__dbh->{AutoCommit}) { my $rc = $sdm->commit;
my $rc = $sdm->__dbh->commit;
unless ($rc) { unless ($rc) {
$log->syslog('err', 'Error at delete member commit: %s', $sdm->errstr); $log->syslog('err', 'Error at delete member commit: %s', $sdm->errstr);
$sdm->__dbh->rollback; $sdm->rollback;
} }
}
return (-1 * $total); return (-1 * $total);
} }
...@@ -3226,7 +3225,7 @@ sub add_list_member { ...@@ -3226,7 +3225,7 @@ sub add_list_member {
my $sdm = Sympa::DatabaseManager->instance; my $sdm = Sympa::DatabaseManager->instance;
$sdm->__dbh->begin_work; $sdm->begin;
foreach my $new_user (@new_users) { foreach my $new_user (@new_users) {
my $who = Sympa::Tools::Text::canonic_email($new_user->{'email'}); my $who = Sympa::Tools::Text::canonic_email($new_user->{'email'});
...@@ -3373,13 +3372,12 @@ sub add_list_member { ...@@ -3373,13 +3372,12 @@ sub add_list_member {
$self->{'add_outcome'}{'remaining_member_to_add'}--; $self->{'add_outcome'}{'remaining_member_to_add'}--;
$current_list_members_count++; $current_list_members_count++;
} }
unless ($sdm->__dbh->{AutoCommit}) { my $rc = $sdm->commit;
my $rc = $sdm->__dbh->commit;
unless ($rc) { unless ($rc) {
$log->syslog('err', 'Error at add member commit: %s', $sdm->errstr); $log->syslog('err', 'Error at add member commit: %s', $sdm->errstr);
$sdm->__dbh->rollback; $sdm->rollback;
} }
}
$self->_cache_publish_expiry('member'); $self->_cache_publish_expiry('member');
$self->_create_add_error_string() if ($self->{'add_outcome'}{'errors'}); $self->_create_add_error_string() if ($self->{'add_outcome'}{'errors'});
......
...@@ -416,7 +416,7 @@ sub _update_users { ...@@ -416,7 +416,7 @@ sub _update_users {
my %to_be_inserted; my %to_be_inserted;
$sdm->__dbh->begin_work; $sdm->begin;
while (my $entry = $ds->next) { while (my $entry = $ds->next) {
my ($email, $gecos) = @$entry; my ($email, $gecos) = @$entry;
...@@ -453,7 +453,7 @@ sub _update_users { ...@@ -453,7 +453,7 @@ sub _update_users {
unless (%res) { unless (%res) {
$ds->close; $ds->close;
$log->syslog('info', '%s: Aborted update', $ds); $log->syslog('info', '%s: Aborted update', $ds);
$sdm->__dbh->rollback; $sdm->rollback;
return; return;
} }
foreach my $res (keys %res) { foreach my $res (keys %res) {
...@@ -465,13 +465,12 @@ sub _update_users { ...@@ -465,13 +465,12 @@ sub _update_users {
} }
} }
unless ($sdm->__dbh->{AutoCommit}) { my $rc = $sdm->commit;
my $rc = $sdm->__dbh->commit;
unless ($rc) { unless ($rc) {
$log->syslog('err', 'Error at update user commit: %s', $sdm->errstr); $log->syslog('err', 'Error at update user commit: %s', $sdm->errstr);
$sdm->__dbh->rollback; $sdm->rollback;
} }
}
my @list_of_new_users; my @list_of_new_users;
for (keys %to_be_inserted) { for (keys %to_be_inserted) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment