Bugzilla – Attachment 99516 Details for
Bug 24715
Cache repeatable subfield in TransformKohaToMarc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24715: Cache repeatable subfield in TransformKohaToMarc
Bug-24715-Cache-repeatable-subfield-in-TransformKo.patch (text/plain), 3.49 KB, created by
Marcel de Rooy
on 2020-02-24 13:20:35 UTC
(
hide
)
Description:
Bug 24715: Cache repeatable subfield in TransformKohaToMarc
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-02-24 13:20:35 UTC
Size:
3.49 KB
patch
obsolete
>From 7206abfc0018435a51dfd1331ca87c6e415ef9b7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 24 Feb 2020 12:52:13 +0000 >Subject: [PATCH] Bug 24715: Cache repeatable subfield in TransformKohaToMarc >Content-Type: text/plain; charset=utf-8 > >Implemented by calling GetMarcSubfieldStructure. > >Test plan: >Run t/db_dependent/Biblio/TransformKohaToMarc.t >Optionally, follow the test plan of bug 21800#comment7. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Biblio.pm | 17 ++++++++++++----- > t/db_dependent/Biblio/TransformKohaToMarc.t | 2 +- > 2 files changed, 13 insertions(+), 6 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 8b55886e4a..73ba9a5f7c 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1990,7 +1990,8 @@ sub TransformKohaToMarc { > > # In the next call we use the Default framework, since it is considered > # authoritative for Koha to Marc mappings. >- my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framewok >+ my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework >+ my $mss2; # belongs to $params->{framework} only filled when needed > my $tag_hr = {}; > while ( my ($kohafield, $value) = each %$hash ) { > foreach my $fld ( @{ $mss->{$kohafield} } ) { >@@ -1999,7 +2000,7 @@ sub TransformKohaToMarc { > next if !$tagfield; > > # BZ 21800: split value if field is repeatable. >- my @values = _check_split($params, $fld, $value) >+ my @values = _check_split($params, $mss2, $fld, $value) > ? split(/\s?\|\s?/, $value, -1) > : ( $value ); > foreach my $value ( @values ) { >@@ -2023,7 +2024,7 @@ sub TransformKohaToMarc { > } > > sub _check_split { >- my ($params, $fld, $value) = @_; >+ my ($params, $mss2, $fld, $value) = @_; > return if index($value,'|') == -1; # nothing to worry about > return if $params->{no_split}; > >@@ -2031,8 +2032,14 @@ sub _check_split { > return $fld->{repeatable} if !$params->{framework}; > > # here we need to check the specific framework >- my $mss = Koha::MarcSubfieldStructures->find( $params->{framework}, $fld->{tagfield}, $fld->{tagsubfield} ); >- return 1 if $mss && $mss->repeatable; >+ $mss2 = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 }) >+ if !$mss2; >+ foreach my $fld2 ( @{ $mss2->{ $fld->{kohafield} } } ) { >+ next if $fld2->{tagfield} ne $fld->{tagfield}; >+ next if $fld2->{tagsubfield} ne $fld->{tagsubfield}; >+ return 1 if $fld2->{repeatable}; >+ } >+ return; > } > > =head2 PrepHostMarcField >diff --git a/t/db_dependent/Biblio/TransformKohaToMarc.t b/t/db_dependent/Biblio/TransformKohaToMarc.t >index fac328d0a5..f22297959b 100644 >--- a/t/db_dependent/Biblio/TransformKohaToMarc.t >+++ b/t/db_dependent/Biblio/TransformKohaToMarc.t >@@ -88,7 +88,7 @@ subtest "Add tests for _check_split" => sub { > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > # add 952a repeatable in another framework > my $fw = $builder->build({ source => 'BiblioFramework' })->{frameworkcode}; >- Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1 })->store; >+ Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1, kohafield => 'items.fld1' })->store; > > # Test single value in fld1 > my @cols = ( 'items.fld1' => '01' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24715
:
99514
|
99515
|
99516
|
99699
|
102992
|
102993
|
103005
|
103006
|
103010