From bc2e3e0d460d856c1b21a52c084697b9800013ff 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 Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit bab6a08ac98c1e6a72b346d554f020c0943e243d) Signed-off-by: Fridolin Somers --- 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 e21f9f4659..3aac2cb276 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.39.5