From 8757023b2167bfec92a494873232f1aaa76ab6be Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 25 Jun 2022 11:18:42 +0000 Subject: [PATCH] Bug 30327: (follow-up) Fix inconsistencies in syspref names and supply defaults This patch fetches the new sysprefs into variables, providing default title ascending if they are not set to avoid an undefined concatenation warning I also make the update idempotent and fix confusion of plural/singular names Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio.pm | 4 +++- .../atomicupdate/bug_30327_add_sortComponents_syspref.pl | 6 +++--- installer/data/mysql/mandatory/sysprefs.sql | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 52cc36f2d6..ea0c9d9f84 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -565,7 +565,9 @@ sub get_components_query { my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); my $marc = $self->metadata->record; - my $sort = C4::Context->preference('ComponentSortField') . "_" . C4::Context->preference('ComponentSortOrder'); + my $component_sort_field = C4::Context->preference('ComponentSortField') // "title"; + my $component_sort_order = C4::Context->preference('ComponentSortOrder') // "asc"; + my $sort = $component_sort_field . "_" . $component_sort_order; my $searchstr; if ( C4::Context->preference('UseControlNumber') ) { diff --git a/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl b/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl index 7c64d24c53..cbc9416f9b 100755 --- a/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl +++ b/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl @@ -2,15 +2,15 @@ use Modern::Perl; return { bug_number => "30327", - description => "Add ComponentsSortField and ComponentsSortOrder sysprefs", + description => "Add ComponentSortField and ComponentSortOrder sysprefs", up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; $dbh->do(q{ - INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), ('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice') }); - say $out "Added ComponentsSortField and ComponentsSortOrder sysprefs"; + say $out "Added ComponentSortField and ComponentSortOrder sysprefs"; }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 0581d044b4..c1162d9f6c 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -144,8 +144,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CoceProviders', '', 'aws,gb,ol', 'Coce providers', 'multiple'), ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'), ('CollapseFieldsPatronAddForm','',NULL,'Collapse these fields by default when adding a new patron. These fields can still be expanded.','Multiple'), -('ComponentsSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), -('ComponentsSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'), +('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), +('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice'), ('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'), ('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo'), ('CreateAVFromCataloguing', '1', '', 'Ability to create authorized values from the cataloguing module', 'YesNo'), -- 2.39.5