Koha/installer/data/mysql/db_revs/221200023.pl
Tomas Cohen Arazi b3d239bca6
Bug 33300: DBRev 22.12.00.023
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-04-24 10:43:23 -03:00

32 lines
1.4 KiB
Perl
Executable file

use Modern::Perl;
return {
bug_number => "33300",
description => "Fix missing wrong system preference 'AutomaticWrongTransfer'",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
my ($wrong_syspref_exists) = $dbh->selectrow_array(q{
SELECT COUNT(*) FROM systempreferences WHERE variable='AutomaticWrongTransfer'
});
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='AutomaticConfirmTransfer'
});
if ( $correct_syspref_exists ) {
$dbh->do(q{
DELETE FROM systempreferences WHERE variable='AutomaticWrongTransfer'
});
say $out "Wrong system preference 'AutomaticWrongTransfer' deleted";
} else {
$dbh->do(q{
UPDATE systempreferences SET variable='AutomaticConfirmTransfer' WHERE variable='AutomaticWrongTransfer'
});
say $out "Wrong system preference 'AutomaticWrongTransfer' renamed 'AutomaticConfirmTransfer'";
}
} else {
say $out "Wrong system preference 'AutomaticWrongTransfer' does not exist";
}
},
};