Bug 28230: Store C4::Message->{metadata} as Perl string always
authorJoonas Kylmälä <joonas.kylmala@helsinki.fi>
Tue, 27 Apr 2021 07:29:21 +0000 (10:29 +0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 28 Apr 2021 09:07:06 +0000 (11:07 +0200)
commiteb1961f682e13724d402d5a3f242bfce00ee3d8e
tree713906e5dce23c61225902661e584315bab6304e
parent62444c1b9f095b98f6bcddd37ea505a43f578730
Bug 28230: Store C4::Message->{metadata} as Perl string always

When loading C4::Message->{metadata} we load it as perl string in all
other cases, see e.g. the subroutine find_last_message(). In this one
case we incorrectly populate the C4::Message->{metadata} as an UTF-8
octet instead of a Perl string. This causes a problem later on because
encode_utf8 later on in the line:

YAML::XS::Load(Encode::encode_utf8($self->{metadata}));

excepts a perl string and not a UTF-8 octet (please refer to the
functions perldoc). This breaks the encoding and causes an internal
server error:

To test the error is gone:
1. Create biblio with "AE" (bugzilla doesn't let me write the real
letter here, see it in the bugzilla comments) in title
2. Enable RenewalSendNotice
3. Enable "Item checkout and renewal" message preference for patron
4. Checkout an item from biblio "AE" to patron
5. Try to renew the patron's loan and notice the renewal fails
6. Apply patch and restart plack
7. Notice renewal works now and message h's the AE letter displayed correctly

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Message.pm