Commit d3cb1b0a authored by joubu's avatar joubu Committed by Kyle M Hall

Bug 17970: Fix GetPreparedLetter behavior if nothing to substitute

From C4::Letters::GetPreparedLetter:

    my $tables = $params{tables};
    my $substitute = $params{substitute};

    $tables || $substitute || $repeat
       or carp( "ERROR: nothing to substitute - both 'tables' and 'substitute' are empty" ),
          return;

So if the parameter tables or substitute is passed but does not contain anything, it will not warn as expected.

Test plan:
1/ Apply the patch with tests
2/ Confirm that they do not pass
3/ Apply this patch
4/ Confirm that the tests now pass
Signed-off-by: Mark Tompsett's avatarMark Tompsett <mtompset@hotmail.com>
Signed-off-by: default avatarMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: default avatarKyle M Hall <kyle@bywatersolutions.com>
parent 52d55197
......@@ -689,15 +689,15 @@ sub GetPreparedLetter {
or warn( "No $module $letter_code letter transported by " . $mtt ),
return;
my $tables = $params{tables};
my $substitute = $params{substitute};
my $tables = $params{tables} || {};
my $substitute = $params{substitute} || {};
my $repeat = $params{repeat};
$tables || $substitute || $repeat
%$tables || %$substitute || $repeat
or carp( "ERROR: nothing to substitute - both 'tables' and 'substitute' are empty" ),
return;
my $want_librarian = $params{want_librarian};
if ($substitute) {
if (%$substitute) {
while ( my ($token, $val) = each %$substitute ) {
if ( $token eq 'items.content' ) {
$val =~ s|\n|<br/>|g if $letter->{is_html};
......@@ -743,7 +743,7 @@ sub GetPreparedLetter {
}
}
if ($tables) {
if (%$tables) {
_substitute_tables( $letter, $tables );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment