Bug 21978: (follow-up) Stop using C4 methods in atomicupdate

We should really only use C4::Context methods where absolutely
necessary.. in this case is was simple to replace the get_preference and
set_preference calls with SQL

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2022-05-18 16:34:50 +01:00 committed by Tomas Cohen Arazi
parent 5a4253aa8e
commit b409b5eb8d
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -33,11 +33,18 @@ return {
});
say $out "Added middle name column to borrower_modifications table";
}
my @default_patron_search_fields = split(',',C4::Context->preference('DefaultPatronSearchFields'));
my ($default_patron_search_fields) = $dbh->selectrow_array( q{
SELECT value FROM systempreferences WHERE variable='DefaultPatronSearchFields';
});
my @default_patron_search_fields = split(',',$default_patron_search_fields);
unless( grep /middle_name/, @default_patron_search_fields ){
if( grep /firstname/, @default_patron_search_fields ){
push @default_patron_search_fields,'middle_name';
C4::Context->set_preference('DefaultPatronSearchFields', join(',',@default_patron_search_fields) );
my $new_patron_search_fields = join(',',@default_patron_search_fields);
$dbh->do(q{
UPDATE systempreferences SET value=? WHERE variable='DefaultPatronSearchFields'
}, undef, $new_patron_search_fields);
say $out "Added middle name to DefaultPatronSearchFields";
} else {
say $out "Please add 'middlename' to DefaultPatronSearchFields if you want it searched by default";