Bugzilla – Attachment 59083 Details for
Bug 17913
Merge three authority merge fixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17913: Do not keep a cleared subfield in loose merge mode
Bug-17913-Do-not-keep-a-cleared-subfield-in-loose-.patch (text/plain), 4.15 KB, created by
Marcel de Rooy
on 2017-01-17 09:54:57 UTC
(
hide
)
Description:
Bug 17913: Do not keep a cleared subfield in loose merge mode
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-01-17 09:54:57 UTC
Size:
4.15 KB
patch
obsolete
>From d589512e10527b9c7548ead8ec1fe17fb349a976 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 17 Jan 2017 09:32:44 +0100 >Subject: [PATCH] Bug 17913: Do not keep a cleared subfield in loose merge mode >Content-Type: text/plain; charset=utf-8 > >If you modify an authority and clear a specific subfield, you expect that >merge respects your edit and clears this subfield too in the biblio >records. It does in the new strict mode, but it does not yet in the >default loose mode. > >This patch fixes that by adjusting the code around $exclude so that it >uses a new hash skip_subfields, built from the reporting tags from the old >and the new authority record. > >This is supported again by some changes in the unit test. > >Test plan: >Run t/db_dependent/Authorities/Merge.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/AuthoritiesMarc.pm | 21 +++++++++++++-------- > t/db_dependent/Authorities/Merge.t | 7 ++++++- > 2 files changed, 19 insertions(+), 9 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 53be7d2..72d64f2 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1467,6 +1467,12 @@ sub merge { > # BulkEdit marc records > # May be used as a template for a bulkedit field > my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict'; >+ my $skip_subfields = $overwrite >+ # This hash contains all subfields from the authority report fields >+ # Including $MARCfrom as well as $MARCto >+ # We only need it in loose merge mode; replaces the former $exclude >+ ? {} >+ : { map { ( $_->[0], 1 ); } ( @record_from, @record_to ) }; > foreach my $marcrecord(@reccache){ > my $update = 0; > foreach my $tagfield (@$tags_using_authtype){ >@@ -1485,17 +1491,16 @@ sub merge { > $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= $overwrite ? () : grep {$_->[0]!~/$exclude/} $field->subfields(); >- foreach my $subfield (@restore) { >- $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >- } >+ if( !$overwrite ) { >+ # add subfields back in loose mode, check skip_subfields >+ foreach my $subfield ( $field->subfields ) { >+ next if $skip_subfields->{ $subfield->[0] }; >+ $field_to->add_subfields( $subfield->[0], $subfield->[1] ); >+ } >+ } > if( $tags_new ) { > $marcrecord->delete_field( $field ); > append_fields_ordered( $marcrecord, $field_to ); >diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t >index 9556c62..0ff66a3 100755 >--- a/t/db_dependent/Authorities/Merge.t >+++ b/t/db_dependent/Authorities/Merge.t >@@ -135,7 +135,7 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { > # Tests were aimed for bug 9988, moved to 17909 in adjusted form > # Would not encourage this type of merge, but we should test what we offer > # The merge routine still needs the fixes on bug 17913 >- plan tests => 12; >+ plan tests => 13; > > # create two auth recs of different type > my $auth1 = MARC::Record->new; >@@ -189,6 +189,11 @@ subtest 'Test merge A1 to B1 (changing authtype)' => sub { > is( $newbiblio->subfield( '112', 'c' ), > $auth2->subfield( '112', 'c' ), 'Check new 112c' ); > >+ # Check 112b; this subfield was cleared when moving from 109 to 112 >+ # Note that this fix only applies to the current loose mode only >+ is( $newbiblio->subfield( '112', 'b' ), undef, >+ 'Merge respects a cleared subfield in loose mode' ); >+ > # Check the original 612 > is( ( $newbiblio->field('612') )[0]->subfield( 'a' ), > $oldbiblio->subfield( '612', 'a' ), 'Check untouched 612a' ); >-- >2.1.4
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 17913
:
59009
|
59010
|
59016
|
59017
|
59065
|
59066
|
59073
|
59078
|
59079
|
59080
|
59081
|
59082
|
59083
|
59084
|
59085
|
59089
|
59090
|
59102
|
59103
|
59104
|
59105
|
59106
|
59107
|
59108
|
59109
|
59110
|
59325
|
59326
|
59327
|
59328
|
59329
|
59330
|
59331
|
59332
|
59333
|
59352
|
59358
|
59360
|
59361
|
59362
|
59363
|
59364
|
59365
|
59366
|
59367
|
59368
|
59369
|
59370
|
59411
|
59412
|
59413
|
60042
|
60043
|
60341
|
60342