From cc856e6672b5e9961e19478d6f1971cdd202d4ac Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Jan 2021 11:16:48 +0100 Subject: [PATCH] Bug 27466: Don't use set_preference from updatedatabase.pl We must never use subroutines or methods from updatedatabase.pl! Having it using C4::Context->set_preference will call Koha::Config::Syspref->store then C4::Log::logaction and finally Koha::Logger->get which will need the log4perl configured correctly (which is not necessary the case when you upgrade). Test plan: git checkout ed3e4540d73c1c3009375ad339e09a2e676fa1bd (20.06.00.022) reset_all Set the value of QuoteOfTheDay to 0 git checkout bug_27466 (master + this patch) updatedatabase => QuoteOfTheDay is an empty string git checkout ed3e4540d73c1c3009375ad339e09a2e676fa1bd (20.06.00.022) reset_all Set the value of QuoteOfTheDay to 1 git checkout bug_27466 (master + this patch) updatedatabase => QuoteOfTheDay is set to "opac" Signed-off-by: David Nind --- installer/data/mysql/updatedatabase.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f18f375a23..6b5db2fcf5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -22596,16 +22596,18 @@ if( CheckVersion( $DBversion ) ) { $DBversion = '20.06.00.023'; if( CheckVersion( $DBversion ) ) { - my $QuoteOfTheDay = C4::Context->preference('QuoteOfTheDay'); + my ( $QuoteOfTheDay ) = $dbh->selectrow_array(q| + SELECT value FROM systempreferences WHERE variable='QuoteOfTheDay' + |); + my $options = $QuoteOfTheDay ? 'opac' : ''; $dbh->do( q| UPDATE systempreferences - SET options = 'intranet,opac', + SET value = ?, + options = 'intranet,opac', explanation = 'Enable or disable display of Quote of the Day on the OPAC and staff interface home page', type = 'multiple' WHERE variable = 'QuoteOfTheDay' - | ); - - C4::Context->set_preference('QuoteOfTheDay', $QuoteOfTheDay ? 'opac' : ''); + |, undef, $options ); NewVersion( $DBversion, 16371, "Quote of the Day (QOTD) for the staff interface " ); } -- 2.11.0