From 0199b1023ea4673a499477eaeba82eb05eafd16b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 18 May 2022 16:34:50 +0100 Subject: [PATCH] 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 --- installer/data/mysql/atomicupdate/bug_21978.pl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_21978.pl b/installer/data/mysql/atomicupdate/bug_21978.pl index 8abb859971c..42d109ef8a4 100755 --- a/installer/data/mysql/atomicupdate/bug_21978.pl +++ b/installer/data/mysql/atomicupdate/bug_21978.pl @@ -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"; -- 2.25.1