Bugzilla – Attachment 59084 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: Remove possible duplicates in strict merge mode
Bug-17913-Remove-possible-duplicates-in-strict-mer.patch (text/plain), 4.47 KB, created by
Marcel de Rooy
on 2017-01-17 10:27:39 UTC
(
hide
)
Description:
Bug 17913: Remove possible duplicates in strict merge mode
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-01-17 10:27:39 UTC
Size:
4.47 KB
patch
obsolete
>From a830705008e3f63cd0a2d37fac72f46bc9060863 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 17 Jan 2017 10:09:40 +0100 >Subject: [PATCH] Bug 17913: Remove possible duplicates in strict merge mode >Content-Type: text/plain; charset=utf-8 > >Since strict mode does not allow additional subfields that would make >identical fields linked to the same authority different, there is no >need to keep them while merging. > >We achieve this goal by simply: >[1] Count the number of same fields linked to mergefrom in strict mode to > eliminate duplicates. >[2] Replaces the if-statement on auth_number by a next. (Tidy follows.) > >Test plan: >Run t/db_dependent/Authorities/Merge.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/AuthoritiesMarc.pm | 11 +++++++++-- > t/db_dependent/Authorities/Merge.t | 9 ++++++++- > 2 files changed, 17 insertions(+), 3 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 72d64f2..7517419 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1477,14 +1477,22 @@ sub merge { > my $update = 0; > foreach my $tagfield (@$tags_using_authtype){ > # warn "tagfield : $tagfield "; >+ my $countfrom = 0; # used in strict mode to remove duplicates > foreach my $field ($marcrecord->field($tagfield)){ > # biblio is linked to authority with $9 subfield containing authid > my $auth_number=$field->subfield("9"); > my $tag=$field->tag(); >+ next if !defined($auth_number) || $auth_number ne $mergefrom; >+ $countfrom++; >+ if( $overwrite && $countfrom > 1 ) { >+ # remove this duplicate in strict mode >+ $marcrecord->delete_field( $field ); >+ $update = 1; >+ next; >+ } > my $newtag = $tags_new > ? _merge_newtag( $tag, $tags_new ) > : $tag; >- if ($auth_number==$mergefrom) { > my $field_to = MARC::Field->new( > $newtag, > $field->indicator(1), >@@ -1508,7 +1516,6 @@ sub merge { > $field->replace_with($field_to); > } > $update=1; >- } > }#for each tag > }#foreach tagfield > my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; >diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t >index 0ff66a3..e3d08f4 100755 >--- a/t/db_dependent/Authorities/Merge.t >+++ b/t/db_dependent/Authorities/Merge.t >@@ -82,7 +82,7 @@ subtest 'Test merge A1 to A2 (within same authtype)' => sub { > > subtest 'Test merge A1 to modified A1' => sub { > # Tests originate from bug 11700 >- plan tests => 9; >+ plan tests => 11; > > # Simulate modifying an authority from auth1old to auth1new > my $auth1old = MARC::Record->new; >@@ -95,6 +95,8 @@ subtest 'Test merge A1 to modified A1' => sub { > my $MARC1 = MARC::Record->new; > $MARC1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Bruce Wayne', 'b' => '2014', '9' => $authid1 )); > $MARC1->append_fields( MARC::Field->new( '245', '', '', 'a' => 'From the depths' )); >+ $MARC1->append_fields( MARC::Field->new( '609', '', '', 'a' => 'Bruce Lee', 'b' => 'Should be cleared too', '9' => $authid1 )); >+ $MARC1->append_fields( MARC::Field->new( '609', '', '', 'a' => 'Bruce Lee', 'c' => 'This is a duplicate to be removed in strict mode', '9' => $authid1 )); > my $MARC2 = MARC::Record->new; > $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 )); > $MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' )); >@@ -128,6 +130,11 @@ subtest 'Test merge A1 to modified A1' => sub { > $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); > $biblio1 = GetMarcBiblio($biblionumber1); > is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' ); >+ is( $biblio1->fields, scalar( $MARC1->fields ) - 1, 'strict mode should remove a duplicate 609' ); >+ is( $biblio1->field(609)->subfields, >+ scalar($auth1new->field('109')->subfields) + 1, >+ 'Check number of subfields in strict mode for the remaining 609' ); >+ # Note: the +1 comes from the added subfield $9 in the biblio > t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); > }; > >-- >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