From 9811b13bc79c74a330087b87846f89a3e0a398db Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 22 Mar 2023 21:09:35 -1000 Subject: [PATCH] Bug 33297: (follow-up) DBRev check wrong preference exists Better db upgrade messages Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 0fdd8ca72edb3c58953ee5dd63956de184a860d9) Signed-off-by: Pedro Amorim --- .../data/mysql/atomicupdate/bug_33297.pl | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_33297.pl b/installer/data/mysql/atomicupdate/bug_33297.pl index 1f94fcc98b..3df7ec1478 100755 --- a/installer/data/mysql/atomicupdate/bug_33297.pl +++ b/installer/data/mysql/atomicupdate/bug_33297.pl @@ -6,20 +6,27 @@ return { up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - # Correct preference may have been generated via interface - my ($correct_syspref_exists) = $dbh->selectrow_array(q{ - SELECT COUNT(*) FROM systempreferences WHERE variable='RetainPatronsSearchTerms' + my ($wrong_syspref_exists) = $dbh->selectrow_array(q{ + SELECT COUNT(*) FROM systempreferences WHERE variable='RetainPatronSearchTerms' }); - if ($correct_syspref_exists) { - $dbh->do(q{ - DELETE FROM systempreferences WHERE variable='RetainPatronSearchTerms' + if ($wrong_syspref_exists) { + # Correct preference may have been generated via interface + my ($correct_syspref_exists) = $dbh->selectrow_array(q{ + SELECT COUNT(*) FROM systempreferences WHERE variable='RetainPatronsSearchTerms' }); - say $out "Wrong system preference 'RetainPatronSearchTerms' deleted"; + if ( $correct_syspref_exists ) { + $dbh->do(q{ + DELETE FROM systempreferences WHERE variable='RetainPatronSearchTerms' + }); + say $out "Wrong system preference 'RetainPatronSearchTerms' deleted"; + } else { + $dbh->do(q{ + UPDATE systempreferences SET variable='RetainPatronsSearchTerms' WHERE variable='RetainPatronSearchTerms' + }); + say $out "Wrong system preference 'RetainPatronSearchTerms' renamed 'RetainPatronsSearchTerms'"; + } } else { - $dbh->do(q{ - UPDATE systempreferences SET variable='RetainPatronsSearchTerms' WHERE variable='RetainPatronSearchTerms' - }); - say $out "Wrong system preference 'RetainPatronSearchTerms' renamed 'RetainPatronsSearchTerms'"; + say $out "Wrong system preference 'RetainPatronSearchTerms' does not exist"; } }, }; -- 2.39.5