From 09a1c727653a91d9bbf75d67d4b592ff358665b1 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/print_notice.pl b/tools/print_notice.pl index 74f2fd059b9..682b5bd5687 100755 --- a/tools/print_notice.pl +++ b/tools/print_notice.pl @@ -38,13 +38,12 @@ 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 $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} : '', id => $message_id, }; -- 2.45.0