Bug 31202: Don't remove optional SIP fields with a value of "0"
If the value of a SIP field is "0", that evaluates to false, so any calls to maybe_add with a value of "0" will not get added to the SIP response message.
Test Plan:
1) Apply this patch
2) prove t/db_dependent/SIP/Message.t
Signed-off-by: Michal Urban <michalurban177@gmail.com>
JK: Adjust commit title
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 8b957a69d4
)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7d2086663e
commit
5775f6c9a9
2 changed files with 8 additions and 2 deletions
|
@ -108,7 +108,10 @@ sub maybe_add {
|
|||
$value =~ s/$regex->{find}/$regex->{replace}/g;
|
||||
}
|
||||
}
|
||||
return (defined($value) && $value) ? add_field($fid, $value) : '';
|
||||
|
||||
return ( defined($value) && length($value) )
|
||||
? add_field( $fid, $value )
|
||||
: '';
|
||||
}
|
||||
|
||||
#
|
||||
|
|
|
@ -115,7 +115,7 @@ subtest 'Test hold_patron_bcode' => sub {
|
|||
|
||||
subtest 'hold_patron_name() tests' => sub {
|
||||
|
||||
plan tests => 2;
|
||||
plan tests => 3;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
|
@ -145,6 +145,9 @@ subtest 'hold_patron_name() tests' => sub {
|
|||
my $resp = C4::SIP::Sip::maybe_add( FID_CALL_NUMBER, $sip_item->hold_patron_name, $server );
|
||||
is( $resp, q{}, "maybe_add returns empty string for SIP item with no hold returns empty string" );
|
||||
|
||||
$resp = C4::SIP::Sip::maybe_add( FID_CALL_NUMBER, "0", $server );
|
||||
is( $resp, q{CS0|}, "maybe_add will create the field of the string '0'" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue