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 <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2022-06-25 11:18:42 +00:00 committed by Tomas Cohen Arazi
parent daab31ab38
commit 8757023b21
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
3 changed files with 8 additions and 6 deletions

View File

@ -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') ) {

View File

@ -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";
},
};

View File

@ -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'),