From 7509301696e0f4e9ed963c4bc5c3d5ed5741c0e6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Sep 2014 15:22:44 +0200 Subject: [PATCH] Bug 7372: (follow-up) does execute this DB entry twice Since this enh has been backported on 3.14, this patch should be applied on 3.16 and master branch in order to update the updatedb entry. It should not be executed twice otherwise the process is stuck on this entry. http://irc.koha-community.org/koha/2014-09-11#i_1567078 --- installer/data/mysql/updatedatabase.pl | 43 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index bfe5f71..eff6e07 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7984,28 +7984,33 @@ if ( CheckVersion($DBversion) ) { $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; - my $av_added = $dbh->do(q| - INSERT INTO authorised_values(category, authorised_value, lib, lib_opac) - SELECT 'ROADTYPE', roadtypeid, road_type, road_type - FROM roadtype; - |); - - my $rt_deleted = $dbh->do(q| - DELETE FROM roadtype - |); + eval { + $dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|); + }; + unless ( $@ ) { + warn "pas erreur"; + my $av_added = $dbh->do(q| + INSERT INTO authorised_values(category, authorised_value, lib, lib_opac) + SELECT 'ROADTYPE', roadtypeid, road_type, road_type + FROM roadtype; + |); - if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) { - $dbh->do(q| - DROP TABLE roadtype; + my $rt_deleted = $dbh->do(q| + DELETE FROM roadtype |); - $dbh->commit; - print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n"; - SetVersion($DBversion); - } else { - print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)"; - $dbh->rollback; - } + if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) { + $dbh->do(q| + DROP TABLE roadtype; + |); + $dbh->commit; + print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n"; + SetVersion($DBversion); + } else { + print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)"; + $dbh->rollback; + } + } $dbh->{AutoCommit} = 1; $dbh->{RaiseError} = 0; } -- 2.1.0