From 6a89455221c51dbc3bd998802b3d6e0501c1c00a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 26 Nov 2021 10:28:33 +0000 Subject: [PATCH] Bug 29457: (follow-up) Add additional information to warnings Signed-off-by: Martin Renvoize --- installer/data/mysql/atomicupdate/bug_29457.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_29457.pl b/installer/data/mysql/atomicupdate/bug_29457.pl index 732c919fbd..ab792bc4c8 100755 --- a/installer/data/mysql/atomicupdate/bug_29457.pl +++ b/installer/data/mysql/atomicupdate/bug_29457.pl @@ -6,7 +6,15 @@ return { up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - my ( $count ) = $dbh->selectrow_array( q{SELECT COUNT(*) FROM accountlines WHERE credit_type_code = 'CANCELLATION' AND manager_id is NULL} ); - say "Note: We counted $count cancellations in accountlines with an empty manager_id. We regret that this information is missing, but it can't hurt. This release fixed the bug causing it." if $count; + my ( $count_bad ) = $dbh->selectrow_array( q{SELECT COUNT(*) FROM accountlines WHERE credit_type_code = 'CANCELLATION' AND manager_id IS NOT NULL} ); + if ( $count_bad ) { + say $out "Warning: We counted $count_bad cancellations in accountlines where the manager_id is likely incorrect."; + say $out "Prior to this patch a users 'userid' was being passed into the manager_id field where borrowernumber is expected"; + say $out "You may wish to run 'UPDATE accountlines SET manager_id = NULL WHERE credit_type_code = 'CANCELLATION'"; + say $out "Alternatively you may wish to run 'UPDATE accountlines SET manager_id = ( SELECT borrowernumber FROM borrowers WHERE borrowers.userid = accountlines.manager_id ) WHERE credit_type_code = 'CANCELLATION''"; + } + + my ( $count_empty ) = $dbh->selectrow_array( q{SELECT COUNT(*) FROM accountlines WHERE credit_type_code = 'CANCELLATION' AND manager_id IS NULL} ); + say $out "Note: We counted $count_empty cancellations in accountlines with an empty manager_id. We regret that this information is missing, but it can't hurt. This release fixed the bug causing it." if $count_empty; }, } -- 2.20.1