Bugzilla – Attachment 135240 Details for
Bug 30813
Refactor TransformMarcToKoha to remove TransformMarcToKohaOneField
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30813: Adjust TransformMarcToKoha to take kohafields parameter
Bug-30813-Adjust-TransformMarcToKoha-to-take-kohaf.patch (text/plain), 2.44 KB, created by
Martin Renvoize (ashimema)
on 2022-05-20 11:17:20 UTC
(
hide
)
Description:
Bug 30813: Adjust TransformMarcToKoha to take kohafields parameter
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-20 11:17:20 UTC
Size:
2.44 KB
patch
obsolete
>From 2739884ec88fd740d2ee203ce1d238f82b1998dd Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 19 May 2022 20:10:35 +0000 >Subject: [PATCH] Bug 30813: Adjust TransformMarcToKoha to take kohafields > parameter > >This adjusts the routine to accept an arrayref of koha fields to process > >To test: >prove -v t/db_dependent/Biblio/TransformMarcToKoha.t t/Biblio.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Biblio.pm | 30 ++++++++++++++++++++++++++---- > 1 file changed, 26 insertions(+), 4 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 24eef00a08..90cc4382fd 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2307,6 +2307,7 @@ sub TransformMarcToKoha { > > my $record = $params->{record}; > my $limit_table = $params->{limit_table} // q{}; >+ my $kohafields = $params->{kohafields}; > > my $result = {}; > if (!defined $record) { >@@ -2324,13 +2325,34 @@ sub TransformMarcToKoha { > # The next call acknowledges Default as the authoritative framework > # for Koha to MARC mappings. > my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # Do not change framework >- foreach my $kohafield ( keys %{ $mss } ) { >+ @{$kohafields} = keys %{ $mss } unless $kohafields; >+ foreach my $kohafield ( @{$kohafields} ) { > my ( $table, $column ) = split /[.]/, $kohafield, 2; > next unless $tables{$table}; >- my $val = TransformMarcToKohaOneField( $kohafield, $record ); >- next if !defined $val; >+ my ( $value, @values ); >+ foreach my $fldhash ( @{$mss->{$kohafield}} ) { >+ my $tag = $fldhash->{tagfield}; >+ my $sub = $fldhash->{tagsubfield}; >+ foreach my $fld ( $record->field($tag) ) { >+ if( $sub eq '@' || $fld->is_control_field ) { >+ push @values, $fld->data if $fld->data; >+ } else { >+ push @values, grep { $_ } $fld->subfield($sub); >+ } >+ } >+ } >+ if ( @values ){ >+ $value = join ' | ', uniq(@values); >+ >+ # Additional polishing for individual kohafields >+ if( $kohafield =~ /copyrightdate|publicationyear/ ) { >+ $value = _adjust_pubyear( $value ); >+ } >+ } >+ >+ next if !defined $value; > my $key = _disambiguate( $table, $column ); >- $result->{$key} = $val; >+ $result->{$key} = $value; > } > return $result; > } >-- >2.20.1
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 30813
:
135232
|
135233
|
135234
|
135235
|
135239
|
135240
|
135241
|
135242
|
135243
|
135302
|
135303
|
135304
|
135305
|
135306
|
135371
|
135374
|
135375
|
135376
|
135377
|
135378
|
135379
|
135763
|
135764
|
135765
|
135766
|
135767
|
135768
|
135769
|
135803
|
135825