From 573101aa62704b6c2605ecc00f1af8934b551d6c Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Fri, 10 Dec 2021 19:33:29 -1000
Subject: [PATCH] Bug 13188: (RM follow-up) Several fixes on db changes

Several issues with the atomic update:
 - File must to be .pl
 - File must be executable : chmod a+x
 - Syspref type is 'free' not 'multiple'

Small addition in atomic update:
I've added a print of syspref name and value,
this can be usefull for upgrade logs.

Also a minor issue in installer/data/mysql/mandatory/sysprefs.sql :
The description whas different from the atomic update.
I choose that atomic update is correct.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
---
 ...tronSelfModificationMandatoryField_syspref.pl} | 15 ++++++++++-----
 installer/data/mysql/mandatory/sysprefs.sql       |  2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)
 rename installer/data/mysql/atomicupdate/{bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl => bug_13188_add_PatronSelfModificationMandatoryField_syspref.pl} (57%)
 mode change 100644 => 100755

diff --git a/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl b/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.pl
old mode 100644
new mode 100755
similarity index 57%
rename from installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl
rename to installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.pl
index 43a3f5105d..55ecd20452
--- a/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl
+++ b/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.pl
@@ -7,10 +7,15 @@ return {
         my ($args) = @_;
         my ($dbh, $out) = @$args{qw(dbh out)};
 
-       $dbh->do(q{
+        $dbh->do(q{
             INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
-            SELECT 'PatronSelfModificationMandatoryField', value, NULL, 'Define the required fields when a patron is editing their information via the OPAC','multiple'
-            FROM (SELECT value FROM systempreferences WHERE variable="PatronSelfRegistrationBorrowerMandatoryField") tmp
-       });
+            SELECT 'PatronSelfModificationMandatoryField', value, NULL, 'Define the required fields when a patron is editing their information via the OPAC','free'
+            FROM (SELECT value FROM systempreferences WHERE variable='PatronSelfRegistrationBorrowerMandatoryField') tmp
+        });
+
+        my ($syspref_value) = $dbh->selectrow_array(q{
+            SELECT value FROM systempreferences WHERE variable='PatronSelfModificationMandatoryField'
+        });
+        say $out "Added new system preference 'PatronSelfModificationMandatoryField' with value '$syspref_value'";
     },
-}
+  }
diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql
index b25a180a97..ba5afc4a80 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -514,7 +514,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'),
 ('patronimages','0',NULL,'Enable patron images for the staff interface','YesNo'),
 ('PatronRemovalDelay','',NULL,'Delay for removing anonymized patrons', 'Integer'),
-('PatronSelfModificationMandatoryField','',NULL,'Name the fields you don\'t want to be required when a patron is editing their information via the OPAC.','free'),
+('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'),
 ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'),
 ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'),
 ('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'),
-- 
2.34.0