From f9ecc5a0a1bc02f6a03a4d79a43c5364139b20b9 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 24 Oct 2018 17:02:39 -0300
Subject: [PATCH] Bug 21651: Always insert notice templates related tables

The 3 following files must be mandatory and insert during the install process:
- message_transport_types.sql
- sample_notices_message_attributes.sql
- sample_notices_message_transports.sql

They insert data for
- message_transport_types
- message_attributes
- message_transport_type

Otherwise the notice templates (table letter) will fail.

Moreover these 3 files are identical and are put in several places (1 per language)
to make the description translatable (using the related .txt file)

Test plan:
- Install Koha in English and in another language
- Select all the sample data
=> They all should be inserted correctly
Note that you cannot select/unselect the checkbox for these 3 tables
---
 C4/Installer.pm | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/C4/Installer.pm b/C4/Installer.pm
index 4d577156ac..b62f8431af 100644
--- a/C4/Installer.pm
+++ b/C4/Installer.pm
@@ -314,15 +314,19 @@ sub load_sql_in_order {
     $request->execute;
     my ($systempreference) = $request->fetchrow;
     $systempreference = '' unless defined $systempreference; # avoid warning
-    # Make sure subtag_registry.sql is loaded second
-    my $subtag_registry = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/mandatory/subtag_registry.sql";
-    unshift(@fnames, $subtag_registry);
-    # Make sure authorised value categories are loaded at the beginning
-    my $av_cat = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/mandatory/auth_val_cat.sql";
-    unshift(@fnames, $av_cat);
-    # Make sure the global sysprefs.sql file is loaded first
-    my $globalsysprefs = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/sysprefs.sql";
-    unshift(@fnames, $globalsysprefs);
+
+    my $global_mandatory_dir = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/mandatory";
+
+    # Make sure some stuffs are loaded first
+    unshift(@fnames, C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/sysprefs.sql");
+    unshift(@fnames,
+        "$global_mandatory_dir/subtag_registry.sql",
+        "$global_mandatory_dir/auth_val_cat.sql",
+        "$global_mandatory_dir/message_transport_types.sql",
+        "$global_mandatory_dir/sample_notices_message_attributes.sql",
+        "$global_mandatory_dir/sample_notices_message_transports.sql",
+    );
+
     push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userflags.sql";
     push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql";
     push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql";
-- 
2.11.0