From 80e1313041a0ddfb9464607c85fd07010c31af27 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 1 Aug 2022 11:38:01 -0300 Subject: [PATCH] Bug 31274: Make sure OPACSuggestionAutoFill is handled as a boolean everywhere The YAML preference definition defines it as a string ('yes' or 'no' the possible values). And the opac-suggestions.tt template has one occurence of the variable being compared to a string. This patch does: - fix the template - fixes opac.pref for 0|1 - adds an atomicupdate that takes care of moving 'yes' and 'no' to their respective boolean values. To test: 1. Change the syspref value to enable/disable 2. Check on the DB that the value is wrong: $ koha-mysql kohadev > SELECT value FROM systempreferences WHERE variable='OPACSuggestionAutoFill'; => FAIL: It is either 'yes' or 'no' depending on what you choose. 3. Apply this patch 4. Run: $ updatedatabase 5. Repeat 2 => SUCCESS: Values are now 0 or 1 6. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Aleisha Amohia --- installer/data/mysql/atomicupdate/bug_31274.pl | 20 ++++++++++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 4 ++-- .../bootstrap/en/modules/opac-suggestions.tt | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_31274.pl diff --git a/installer/data/mysql/atomicupdate/bug_31274.pl b/installer/data/mysql/atomicupdate/bug_31274.pl new file mode 100755 index 0000000000..0f2865dc60 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31274.pl @@ -0,0 +1,20 @@ +use Modern::Perl; + +return { + bug_number => "31274", + description => "OPACSuggestionAutoFill must be 1 or 0", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ + UPDATE systempreferences + SET value = CASE + WHEN value='no' THEN 0 + WHEN value='yes' THEN 1 + ELSE value + END + WHERE variable='OPACSuggestionAutoFill'; + }); + }, +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index d7d1649a3f..c9e25aa478 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -518,8 +518,8 @@ OPAC: - pref: OPACSuggestionAutoFill default: 0 choices: - yes: Enable - no: Disable + 1: Enable + 0: Disable - OPAC suggestions form automatically filling with data from Google Books API. - - "Use the following as the OPAC ISBD template:" diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index cdc7927a5c..9cfd86c2f1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -497,7 +497,7 @@ [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] -[% IF ( Koha.Preference("OPACSuggestionAutoFill") != 'no' ) %] +[% IF Koha.Preference("OPACSuggestionAutoFill") %] [% Asset.js("js/autofill.js") | $raw %] [% END %] [% INCLUDE 'datatables.inc' %] -- 2.11.0