Bug 18801: [Follow-up] Dbrev to repair bad auth type codes
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 15 Jun 2017 13:47:21 +0000 (15:47 +0200)
committerKatrin Fischer <katrin.fischer.83@web.de>
Sun, 29 Oct 2017 17:38:26 +0000 (18:38 +0100)
Test plan
Run updatedatabase.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit aa03981e79a10bd5a032f13533d93f0b87bd37f7)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit ed45e76bf928a5c929525b8f2795524ada217a1e)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

installer/data/mysql/atomicupdate/bug18801.perl [new file with mode: 0644]

diff --git a/installer/data/mysql/atomicupdate/bug18801.perl b/installer/data/mysql/atomicupdate/bug18801.perl
new file mode 100644 (file)
index 0000000..8a8fd50
--- /dev/null
@@ -0,0 +1,15 @@
+$DBversion = 'XXX';  # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    # Fetch all auth types
+    my $authtypes = $dbh->selectcol_arrayref( q|SELECT authtypecode FROM auth_types| );
+
+    if( grep { $_ eq 'Default' } @$authtypes ) {
+        # If this exists as an authtypecode, we don't do anything
+    } else {
+        # Replace the incorrect Default by empty string
+        $dbh->do( q|UPDATE auth_header SET authtypecode='' WHERE authtypecode='Default'| );
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 18801 - Update incorrect Default auth type codes)\n";
+}