From 955d3b52c00d309172cb70d876b8e0a78eda04a3 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 --- .../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.0