@@ -, +, @@ leave 'Library' and 'Koha module' options as default selections. Enter 'KOHA_14206' and 'Koha Test 14206' against Code and Name respectively, and 'Test' and 'Test Message' for subject and body. Leave the Email, Phone and SMS tabs blank. Save the notice. delete it. It will load the 'Delete notice' dialog form, but the table will not show any data under s - 'Library', 'Module', 'Code' or 'Name'. Notices listing reloaded. The print-only KOHA_14206 notice should continue to exist. This is *wrong*. KOHA_14206. This time, it should show the data under 'Module', 'Code' or 'Name' at least. reload. This time KOHA_14206 will be gone. All tests should PASS without any error. --- C4/Letters.pm | 7 ++++--- t/db_dependent/Letters.t | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -207,8 +207,7 @@ sub GetLettersAvailableForALibrary { our %letter; sub getletter { my ( $module, $code, $branchcode, $message_transport_type ) = @_; - $message_transport_type ||= 'email'; - + $message_transport_type //= '%'; if ( C4::Context->preference('IndependentBranches') and $branchcode @@ -226,7 +225,8 @@ sub getletter { my $sth = $dbh->prepare(q{ SELECT * FROM letter - WHERE module=? AND code=? AND (branchcode = ? OR branchcode = '') AND message_transport_type = ? + WHERE module=? AND code=? AND (branchcode = ? OR branchcode = '') + AND message_transport_type LIKE ? ORDER BY branchcode DESC LIMIT 1 }); $sth->execute( $module, $code, $branchcode, $message_transport_type ); @@ -237,6 +237,7 @@ sub getletter { return { %$line }; } + =head2 DelLetter DelLetter( --- a/t/db_dependent/Letters.t +++ a/t/db_dependent/Letters.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 58; +use Test::More tests => 60; use Test::MockModule; use Test::Warn; @@ -173,6 +173,12 @@ is( $letter->{title}, $title, 'GetLetters gets the title correctly' ); is( $letter->{content}, $content, 'GetLetters gets the content correctly' ); is( $letter->{message_transport_type}, 'email', 'GetLetters gets the message type correctly' ); +# Regression test for Bug 14206 +$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('FFL','my module','my code','my name',1,?,?,'print')|, undef, $title, $content ); +my $letter14206_a = C4::Letters::getletter('my module', 'my code', 'FFL' ); +is( $letter14206_a->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type not passed, correct mtt detected' ); +my $letter14206_b = C4::Letters::getletter('my module', 'my code', 'FFL', 'print'); +is( $letter14206_b->{message_transport_type}, 'print', 'Bug 14206 - message_transport_type passed, correct mtt detected' ); # addalert my $type = 'my type'; --