From eb89e630345c35740937a3f6e6875f7535edfc27 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Oct 2021 17:51:52 +0200 Subject: [PATCH] Bug 28445: Split and join on ' | ' instead of '|' for repeatable Is that correct?! --- Koha/Item/Attributes.pm | 4 ++-- t/db_dependent/Koha/Item/Attributes.t | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Koha/Item/Attributes.pm b/Koha/Item/Attributes.pm index d75a5c44f6a..0c91d3e4431 100644 --- a/Koha/Item/Attributes.pm +++ b/Koha/Item/Attributes.pm @@ -60,7 +60,7 @@ sub new_from_marcxml { my $more_subfields = [ uniq map { $_->[0] } $field->subfields ]; for my $more_subfield (@$more_subfields) { my @s = $field->subfield($more_subfield); - $self->{$more_subfield} = join '|', @s; + $self->{$more_subfield} = join ' | ', @s; } } return bless $self, $class; @@ -113,7 +113,7 @@ sub to_marcxml { or $self->{$tagsubfield} eq ""; if ( $tagslib->{$itemtag}->{$tagsubfield}->{repeatable} ) { - my @values = split '\|', $self->{$tagsubfield}; + my @values = split ' \| ', $self->{$tagsubfield}; push @subfields, ( $tagsubfield => $_ ) for @values; } else { diff --git a/t/db_dependent/Koha/Item/Attributes.t b/t/db_dependent/Koha/Item/Attributes.t index c78a397a52d..8a46b318fee 100755 --- a/t/db_dependent/Koha/Item/Attributes.t +++ b/t/db_dependent/Koha/Item/Attributes.t @@ -66,7 +66,7 @@ my $some_marc_xml = q{ value for y value for é 1 value for é 2 - value for z 1|value for z 2 + value for z 1 | value for z 2 @@ -76,19 +76,19 @@ $item->more_subfields_xml($some_marc_xml)->store; $attributes = $item->additional_attributes; is( ref($attributes), 'Koha::Item::Attributes' ); -is( $attributes->{'x'}, "value for x 1|value for x 2"); +is( $attributes->{'x'}, "value for x 1 | value for x 2"); is( $attributes->{'y'}, "value for y"); -is( $attributes->{'é'}, "value for é 1|value for é 2"); -is( $attributes->{'z'}, "value for z 1|value for z 2"); +is( $attributes->{'é'}, "value for é 1 | value for é 2"); +is( $attributes->{'z'}, "value for z 1 | value for z 2"); is( $attributes->to_marcxml, $some_marc_xml ); is_deeply( $attributes->to_hashref, { - 'x' => "value for x 1|value for x 2", + 'x' => "value for x 1 | value for x 2", 'y' => "value for y", - 'é' => "value for é 1|value for é 2", - 'z' => "value for z 1|value for z 2", + 'é' => "value for é 1 | value for é 2", + 'z' => "value for z 1 | value for z 2", } ); -- 2.25.1