From dd966d54bc5929620adfbd4f1396557a09e6d89a Mon Sep 17 00:00:00 2001 From: Emily Lamancusa Date: Thu, 7 Nov 2024 10:28:55 -0500 Subject: [PATCH] Bug 38299: Use say_failure when printing update errors to the console Bug 35681 added subroutines to print colored output from database updates. Incorporate the subroutine say_failure into the error handling in the upstream code, so that errors caught upstream can take advantage of this new subroutine and display in red. To test: 1. Apply patch for test dbrev 2. From the kshell, run updatedatabase --> The messages for success, info, warning, and failure that were explicitly printed in the dbrev are colored, but the database error is not colored. 3. Apply other patches 4. Run updatedatabase again --> All messages including the database error are now colored Signed-off-by: David Nind Signed-off-by: Jonathan Druart --- installer/data/mysql/updatedatabase.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3ce6a4ccca6..a491bcf0220 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -42,6 +42,7 @@ use Koha::Database; use Koha; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Caches; +use Koha::Installer::Output qw ( say_failure ); use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); @@ -24301,7 +24302,7 @@ unless ( $ENV{HTTP_HOST} ) { # Is that correct? } for my $e ( @{ $report->{error} } ) { say Encode::encode_utf8(join "\n", @{$e->{output}}); - say Encode::encode_utf8("ERROR - " . $e->{error}); + say_failure( undef, Encode::encode_utf8("ERROR - " . $e->{error}) ); $error_code = 1; } @@ -24312,7 +24313,7 @@ unless ( $ENV{HTTP_HOST} ) { # Is that correct? } for my $e ( @{ $report->{error} } ) { say Encode::encode_utf8(join "\n", @{$e->{output}}); - say Encode::encode_utf8("ERROR - " . $e->{error}); + say_failure( undef, Encode::encode_utf8("ERROR - " . $e->{error}) ); $error_code = 1; } exit $error_code; -- 2.34.1