From 26150b85bde59b623de35c2ee55e4e5554968f2a Mon Sep 17 00:00:00 2001 From: Yadd Date: Tue, 29 Jun 2021 19:30:44 +0200 Subject: [PATCH] Fix RDBI rollback --- .../lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm index 77b2959c3..08010c553 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/RDBI.pm @@ -19,11 +19,7 @@ sub store { $req = $self->_dbh->prepare( "INSERT INTO $self->{dbiTable} (cfgNum,field,value) VALUES (?,?,?)"); - if ( $lastCfg == $cfgNum ) { - my $r = - $self->_dbh->prepare("DELETE FROM $self->{dbiTable} where cfgNum=?"); - $r->execute($cfgNum); - } + _delete($self,$cfgNum) if $lastCfg == $cfgNum; unless ($req) { $self->logError; return UNKNOWN_ERROR; @@ -35,6 +31,7 @@ sub store { print STDERR $@ if $@; unless ($execute) { $self->logError; + _delete( $self, $cfgNum ) if $lastCfg != $cfgNum; $self->_dbh->do("ROLLBACK"); return UNKNOWN_ERROR; } @@ -63,5 +60,11 @@ sub load { return $self->unserialize($res); } +sub _delete { + my ( $self, $cfgNum ) = @_; + my $r = + $self->_dbh->prepare("DELETE FROM $self->{dbiTable} where cfgNum=?"); + $r->execute($cfgNum); +} + 1; -__END__