From 78c1f209f708a1b0341b718894b0d4592cbe8eed Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 7 May 2024 19:41:46 +0100 Subject: [PATCH] Bug 33260: (QA follow-up) Safely continue for non-templated notices The 'letter_id'/'letter_code' field in the message queue table is a NULLable foreign key as is indeed NULL in certain circustances. We need to gracefully degrade when there isn't a template for the notice in question. Tihs patch uses the newly introduced 'template' accessor and when that returns undefined we pass 'style' as an empty string. We also use the 'is_html' method introduced in bug 35285 to set the html flag. Signed-off-by: Martin Renvoize --- tools/print_notice.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/print_notice.pl b/tools/print_notice.pl index 74f2fd059b9..a4b43647fe5 100644 --- a/tools/print_notice.pl +++ b/tools/print_notice.pl @@ -37,14 +37,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my @message_ids = $input->multi_param('message_ids'); my @slips; foreach my $message_id (@message_ids) { - my $message = Koha::Notice::Messages->find($message_id); - - my $template = Koha::Notice::Templates->find( $message->letter_id )->unblessed; + my $message = Koha::Notice::Messages->find($message_id); + my $template = $message->template; push @slips, { content => $message->content, - is_html => $template->{is_html}, - style => $template->{style}, + is_html => $message->is_html, + style => $template ? $template->{style} : undef, id => $message_id, }; -- 2.48.1