Bugzilla – Attachment 59332 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: We always need some housekeeping
Bug-17913-We-always-need-some-housekeeping.patch (text/plain), 7.03 KB, created by
Marcel de Rooy
on 2017-01-20 10:46:04 UTC
(
hide
)
Description:
Bug 17913: We always need some housekeeping
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-01-20 10:46:04 UTC
Size:
7.03 KB
patch
obsolete
>From aae0010a56d1948ea40e26e51ae0fcac36ad4df8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 17 Jan 2017 11:37:55 +0100 >Subject: [PATCH] Bug 17913: We always need some housekeeping >Content-Type: text/plain; charset=utf-8 > >Remove some commented warnings >Remove the commented old code at the end of sub merge >Explicitly set merge mode in the first subtest >Move the return to loose mode from the second subtest to the third > >Test plan: >Run t/db_dependent/Authorities/Merge.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/AuthoritiesMarc.pm | 64 ++++---------------------------------- > t/db_dependent/Authorities/Merge.t | 12 ++++--- > 2 files changed, 14 insertions(+), 62 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 7517419..e920c01 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -1455,7 +1455,6 @@ sub merge { > $z++; > } > $oResult->destroy(); >- #warn scalar(@reccache)." biblios to update"; > # Get All candidate Tags for the change > # (This will reduce the search scope in marc records). > my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; >@@ -1464,8 +1463,7 @@ sub merge { > if ($authtypeto->authtypecode ne $authtypefrom->authtypecode){ > $tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); > } >- # 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 >@@ -1476,11 +1474,9 @@ sub merge { > foreach my $marcrecord(@reccache){ > 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 $auth_number = $field->subfield("9"); # link to authority > my $tag=$field->tag(); > next if !defined($auth_number) || $auth_number ne $mergefrom; > $countfrom++; >@@ -1516,8 +1512,8 @@ sub merge { > $field->replace_with($field_to); > } > $update=1; >- }#for each tag >- }#foreach tagfield >+ } >+ } > my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; > my $biblionumber; > if ($bibliotag<10){ >@@ -1535,57 +1531,9 @@ sub merge { > $counteditedbiblio++; > warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); > } >- }#foreach $marc >+ } > return $counteditedbiblio; >- # now, find every other authority linked with this authority >- # now, find every other authority linked with this authority >-# my $oConnection=C4::Context->Zconn("authorityserver"); >-# my $query; >-# # att 9210 Auth-Internal-authtype >-# # att 9220 Auth-Internal-LN >-# # ccl.properties to add for authorities >-# $query= "= ".$mergefrom; >-# my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); >-# my $count=$oResult->size() if ($oResult); >-# my @reccache; >-# my $z=0; >-# while ( $z<$count ) { >-# my $rec; >-# $rec=$oResult->record($z); >-# my $marcdata = $rec->raw(); >-# push @reccache, $marcdata; >-# $z++; >-# } >-# $oResult->destroy(); >-# foreach my $marc(@reccache){ >-# my $update; >-# my $marcrecord; >-# $marcrecord = MARC::File::USMARC::decode($marc); >-# foreach my $tagfield (@tags_using_authtype){ >-# $tagfield=substr($tagfield,0,3); >-# my @tags = $marcrecord->field($tagfield); >-# foreach my $tag (@tags){ >-# my $tagsubs=$tag->subfield("9"); >-# #warn "$tagfield:$tagsubs:$mergefrom"; >-# if ($tagsubs== $mergefrom) { >-# $tag->update("9" =>$mergeto); >-# foreach my $subfield (@record_to) { >-# # warn "$subfield,$subfield->[0],$subfield->[1]"; >-# $tag->update($subfield->[0] =>$subfield->[1]); >-# }#for $subfield >-# } >-# $marcrecord->delete_field($tag); >-# $marcrecord->add_fields($tag); >-# $update=1; >-# }#for each tag >-# }#foreach tagfield >-# my $authoritynumber = TransformMarcToKoha($marcrecord,"") ; >-# if ($update==1){ >-# &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ; >-# } >-# >-# }#foreach $marc >-}#sub >+} > > sub _merge_newtag { > # Routine is only called for an (exceptional) authtypecode change >diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t >index 9267140..2d53272 100755 >--- a/t/db_dependent/Authorities/Merge.t >+++ b/t/db_dependent/Authorities/Merge.t >@@ -43,6 +43,9 @@ subtest 'Test merge A1 to A2 (within same authtype)' => sub { > # Tests originate from bug 11700 > plan tests => 9; > >+ # Start in loose mode, although it actually does not matter here >+ t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); >+ > # Add two authority records > my $auth1 = MARC::Record->new; > $auth1->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'George Orwell' )); >@@ -82,7 +85,7 @@ subtest 'Test merge A1 to A2 (within same authtype)' => sub { > 'Check biblio2 609$a' ); > }; > >-subtest 'Test merge A1 to modified A1' => sub { >+subtest 'Test merge A1 to modified A1, test strict mode' => sub { > # Tests originate from bug 11700 > plan tests => 11; > >@@ -105,7 +108,7 @@ subtest 'Test merge A1 to modified A1' => sub { > my ( $biblionumber1 ) = AddBiblio( $MARC1, ''); > my ( $biblionumber2 ) = AddBiblio( $MARC2, ''); > >- # Time to merge >+ # Time to merge in loose mode first > @zebrarecords = ( $MARC1, $MARC2 ); > $index = 0; > t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); >@@ -139,15 +142,16 @@ subtest 'Test merge A1 to modified A1' => sub { > 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'); > }; > > 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 => 13; > >+ # Get back to loose mode now >+ t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); >+ > # create two auth recs of different type > my $auth1 = MARC::Record->new; > $auth1->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'George Orwell', b => 'bb' )); >-- >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