@@ -, +, @@ and suply defaults --- 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(-) --- a/Koha/Biblio.pm +++ a/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') ) { --- a/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl +++ a/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"; }, }; --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/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'), --