Bugzilla – Attachment 36847 Details for
Bug 13760
Authorities merge sometimes create duplicate fields in biblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13760 - formatting code
Bug-13760---formatting-code.patch (text/plain), 4.29 KB, created by
Fridolin Somers
on 2015-03-13 09:26:54 UTC
(
hide
)
Description:
Bug 13760 - formatting code
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2015-03-13 09:26:54 UTC
Size:
4.29 KB
patch
obsolete
>From 931aa1467d6383f3560342f03fafb9cff8dad5b1 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 13 Mar 2015 10:26:12 +0100 >Subject: [PATCH] Bug 13760 - formatting code > >--- > C4/AuthoritiesMarc.pm | 68 +++++++++++++++++++++++++++++---------------------- > 1 file changed, 39 insertions(+), 29 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index a58ab73..ef4fc54 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1517,37 +1517,45 @@ sub merge { > # biblio is linked to authority with $9 subfield containing authid > my $auth_number=$field->subfield("9"); > my $tag=$field->tag(); >- if ($auth_number==$mergefrom) { >- # If merging distinct authorities, >- # look if field to add already exists in the record >- # in order to avoid a duplicate. >- my $field_to_exists; >- if ( $mergefrom != $mergeto ) { >- foreach ( $marcrecord->field( $tag_to ? $tag_to : $tag ) ) { >- if ( $_->subfield('9') && $_->subfield('9') == $mergeto ) { >- $field_to_exists = 1; >- last; >+ if ( $auth_number == $mergefrom ) { >+ >+ # If merging distinct authorities, >+ # look if field to add already exists in the record >+ # in order to avoid a duplicate. >+ my $field_to_exists; >+ if ( $mergefrom != $mergeto ) { >+ foreach ( $marcrecord->field( $tag_to ? $tag_to : $tag ) ) { >+ if ( $_->subfield('9') && $_->subfield('9') == $mergeto ) { >+ $field_to_exists = 1; >+ last; >+ } > } > } >- } >- # Go editing >- $marcrecord->delete_field($field); >- unless ($field_to_exists) { >- my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); >- my $exclude='9'; >- foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { >- $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >- $exclude.= $subfield->[0]; >- } >- $exclude='['.$exclude.']'; >-# add subfields in $field not included in @record_to >- my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); >- foreach my $subfield (@restore) { >- $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >- } >- $marcrecord->insert_grouped_field($field_to); >- } >- $update=1; >+ >+ # Go editing >+ $marcrecord->delete_field($field); >+ unless ($field_to_exists) { >+ my $field_to = MARC::Field->new( >+ ( $tag_to ? $tag_to : $tag ), >+ $field->indicator(1), >+ $field->indicator(2), "9" => $mergeto >+ ); >+ my $exclude = '9'; >+ foreach my $subfield ( grep { $_->[0] ne '9' } @record_to ) { >+ $field_to->add_subfields( $subfield->[0] => $subfield->[1] ); >+ $exclude .= $subfield->[0]; >+ } >+ $exclude = '[' . $exclude . ']'; >+ >+ # add subfields in $field not included in @record_to >+ my @restore = >+ grep { $_->[0] !~ /$exclude/ } $field->subfields(); >+ foreach my $subfield (@restore) { >+ $field_to->add_subfields( $subfield->[0] => $subfield->[1] ); >+ } >+ $marcrecord->insert_grouped_field($field_to); >+ } >+ $update = 1; > } > }#for each tag > }#foreach tagfield >@@ -1653,6 +1661,8 @@ sub get_auth_type_location { > > END { } # module clean-up code here (global destructor) > >+ >+ > 1; > __END__ > >-- >2.1.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 13760
:
36168
|
36846
| 36847