Bug 19096: DBRev 17.12.00.002
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 11 Dec 2017 14:22:41 +0000 (11:22 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 11 Dec 2017 14:34:18 +0000 (11:34 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha.pm
installer/data/mysql/atomicupdate/bug19096.perl [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index 80fcf3d..2cd477f 100644 (file)
--- a/Koha.pm
+++ b/Koha.pm
@@ -29,7 +29,7 @@ use vars qw{ $VERSION };
 # - #4 : the developer version. The 4th number is the database subversion.
 #        used by developers when the database changes. updatedatabase take care of the changes itself
 #        and is automatically called by Auth.pm when needed.
-$VERSION = "17.12.00.001";
+$VERSION = "17.12.00.002";
 
 sub version {
     return $VERSION;
diff --git a/installer/data/mysql/atomicupdate/bug19096.perl b/installer/data/mysql/atomicupdate/bug19096.perl
deleted file mode 100644 (file)
index c392fd6..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-$DBversion = 'XXX';  # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-
-    my $dbh = C4::Context->dbh;
-
-    my $msss = $dbh->selectall_arrayref(q|
-        SELECT kohafield, tagfield, tagsubfield, frameworkcode
-        FROM marc_subfield_structure
-        WHERE   frameworkcode != ''
-    |, { Slice => {} });
-
-
-    my $sth = $dbh->prepare(q|
-        SELECT kohafield
-        FROM marc_subfield_structure
-        WHERE frameworkcode = ''
-        AND tagfield = ?
-        AND tagsubfield = ?
-    |);
-
-    my @exceptions;
-    for my $mss ( @$msss ) {
-        $sth->execute($mss->{tagfield}, $mss->{tagsubfield} );
-        my ( $default_kohafield ) = $sth->fetchrow_array();
-        if( $mss->{kohafield} ) {
-            push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => $mss->{kohafield} } if not $default_kohafield or $default_kohafield ne $mss->{kohafield};
-        } else {
-            push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => q{} } if $default_kohafield;
-        }
-    }
-
-    if (@exceptions) {
-        print
-"WARNING: The Default framework is now considered as authoritative for Koha to MARC mappings. We have found that your additional frameworks contained "
-          . scalar(@exceptions)
-          . " mapping(s) that deviate from the standard mappings. Please look at the following list and consider if you need to add them again in Default (possibly as a second mapping).\n";
-        for my $exception (@exceptions) {
-            print "Field "
-              . $exception->{tagfield} . '$'
-              . $exception->{tagsubfield}
-              . " in framework "
-              . $exception->{frameworkcode} . ': ';
-            if ( $exception->{kohafield} ) {
-                print "Mapping to "
-                  . $exception->{kohafield}
-                  . " has been adjusted.\n";
-            }
-            else {
-                print "Mapping has been reset.\n";
-            }
-        }
-
-        # Sync kohafield
-
-        # Clear the destination frameworks first
-        $dbh->do(q|
-            UPDATE marc_subfield_structure
-            SET kohafield = NULL
-            WHERE   frameworkcode > ''
-                AND     Kohafield > ''
-        |);
-
-        # Now copy from Default
-        my $msss = $dbh->selectall_arrayref(q|
-            SELECT kohafield, tagfield, tagsubfield
-            FROM marc_subfield_structure
-            WHERE   frameworkcode = ''
-                AND     kohafield > ''
-        |, { Slice => {} });
-        my $sth = $dbh->prepare(q|
-            UPDATE marc_subfield_structure
-            SET kohafield = ?
-            WHERE frameworkcode > ''
-            AND tagfield = ?
-            AND tagsubfield = ?
-        |);
-        for my $mss (@$msss) {
-            $sth->execute( $mss->{kohafield}, $mss->{tagfield},
-                $mss->{tagsubfield} );
-        }
-
-        # Clear the cache
-        my @frameworkcodes = $dbh->selectall_arrayref(q|
-            SELECT frameworkcode FROM biblio_framework WHERE frameworkcode > ''
-        |);
-        for my $frameworkcode (@frameworkcodes) {
-            Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
-        }
-        Koha::Caches->get_instance->clear_from_cache("default_value_for_mod_marc-");
-    }
-
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 19096 - Make Default authoritative for Koha to MARC mappings)\n";
-}
index ec8760d..d7fffc4 100755 (executable)
@@ -15072,6 +15072,98 @@ if( CheckVersion( $DBversion ) ) {
     print "Upgrade to $DBversion done (Bug 19724 - Add [deleted]biblio_metadata.timestamp)\n";
 }
 
+$DBversion = '17.12.00.002';
+if( CheckVersion( $DBversion ) ) {
+
+    my $msss = $dbh->selectall_arrayref(q|
+        SELECT kohafield, tagfield, tagsubfield, frameworkcode
+        FROM marc_subfield_structure
+        WHERE   frameworkcode != ''
+    |, { Slice => {} });
+
+
+    my $sth = $dbh->prepare(q|
+        SELECT kohafield
+        FROM marc_subfield_structure
+        WHERE frameworkcode = ''
+        AND tagfield = ?
+        AND tagsubfield = ?
+    |);
+
+    my @exceptions;
+    for my $mss ( @$msss ) {
+        $sth->execute($mss->{tagfield}, $mss->{tagsubfield} );
+        my ( $default_kohafield ) = $sth->fetchrow_array();
+        if( $mss->{kohafield} ) {
+            push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => $mss->{kohafield} } if not $default_kohafield or $default_kohafield ne $mss->{kohafield};
+        } else {
+            push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => q{} } if $default_kohafield;
+        }
+    }
+
+    if (@exceptions) {
+        print "WARNING: The Default framework is now considered as authoritative for Koha to MARC mappings. We have found that your additional frameworks contained "
+          . scalar(@exceptions)
+          . " mapping(s) that deviate from the standard mappings. Please look at the following list and consider if you need to add them again in Default (possibly as a second mapping).\n";
+        for my $exception (@exceptions) {
+            print "Field "
+              . $exception->{tagfield} . '$'
+              . $exception->{tagsubfield}
+              . " in framework "
+              . $exception->{frameworkcode} . ': ';
+            if ( $exception->{kohafield} ) {
+                print "Mapping to "
+                  . $exception->{kohafield}
+                  . " has been adjusted.\n";
+            }
+            else {
+                print "Mapping has been reset.\n";
+            }
+        }
+
+        # Sync kohafield
+
+        # Clear the destination frameworks first
+        $dbh->do(q|
+            UPDATE marc_subfield_structure
+            SET kohafield = NULL
+            WHERE   frameworkcode > ''
+                AND     Kohafield > ''
+        |);
+
+        # Now copy from Default
+        my $msss = $dbh->selectall_arrayref(q|
+            SELECT kohafield, tagfield, tagsubfield
+            FROM marc_subfield_structure
+            WHERE   frameworkcode = ''
+                AND     kohafield > ''
+        |, { Slice => {} });
+        my $sth = $dbh->prepare(q|
+            UPDATE marc_subfield_structure
+            SET kohafield = ?
+            WHERE frameworkcode > ''
+            AND tagfield = ?
+            AND tagsubfield = ?
+        |);
+        for my $mss (@$msss) {
+            $sth->execute( $mss->{kohafield}, $mss->{tagfield},
+                $mss->{tagsubfield} );
+        }
+
+        # Clear the cache
+        my @frameworkcodes = $dbh->selectall_arrayref(q|
+            SELECT frameworkcode FROM biblio_framework WHERE frameworkcode > ''
+        |);
+        for my $frameworkcode (@frameworkcodes) {
+            Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
+        }
+        Koha::Caches->get_instance->clear_from_cache("default_value_for_mod_marc-");
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 19096 - Make Default authoritative for Koha to MARC mappings)\n";
+}
+
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.