Bugzilla – Attachment 3099 Details for
Bug 5717
Some search results appear as "No Title" when zebraqueue is used instead rebuild_zebra.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adds the record fixing subroutines from rebuild_zebra.pl in zebraqueue_daemon.pl
0001-Adds-the-record-fixing-subroutines-from-rebuild_zebr.patch (text/plain), 4.78 KB, created by
Frédérick Capovilla
on 2011-02-08 18:25:43 UTC
(
hide
)
Description:
Adds the record fixing subroutines from rebuild_zebra.pl in zebraqueue_daemon.pl
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2011-02-08 18:25:43 UTC
Size:
4.78 KB
patch
obsolete
>From e39931297e79ea1b650ace57ad8dcb92cbc38d8e Mon Sep 17 00:00:00 2001 >From: =?utf-8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= <frederick.capovilla@sys-tech.net> >Date: Tue, 8 Feb 2011 13:20:46 -0500 >Subject: [PATCH] Adds the record fixing subroutines from rebuild_zebra.pl in zebraqueue_daemon.pl > >--- > misc/bin/zebraqueue_daemon.pl | 99 ++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 97 insertions(+), 2 deletions(-) > >diff --git a/misc/bin/zebraqueue_daemon.pl b/misc/bin/zebraqueue_daemon.pl >index 6181a94..4383c72 100755 >--- a/misc/bin/zebraqueue_daemon.pl >+++ b/misc/bin/zebraqueue_daemon.pl >@@ -227,10 +227,21 @@ sub process_update { > my $marcxml; > if ($server eq "biblioserver") { > my $marc = GetMarcBiblio($record_number); >- $marcxml = $marc->as_xml_record() if $marc; >+ if($marc) { >+ fix_leader($marc); >+ if(fix_biblio_ids($dbh, $marc, $record_number)) { >+ fix_unimarc_100($marc) if C4::Context->preference("marcflavour") eq "UNIMARC"; >+ $marcxml = $marc->as_xml_record(); >+ } >+ } > } > elsif ($server eq "authorityserver") { >- $marcxml = C4::AuthoritiesMarc::GetAuthorityXML($record_number); >+ my $marc = C4::AuthoritiesMarc::GetAuthority($record_number); >+ if($marc) { >+ fix_authority_id($marc, $record_number); >+ fix_unimarc_100($marc) if C4::Context->preference("marcflavour") eq "UNIMARC"; >+ $marcxml = $marc->as_xml_record(); >+ } > } > # check it's XML, just in case > eval { >@@ -442,6 +453,90 @@ sub get_zebra_connection { > } > } > >+sub fix_leader { >+ # FIXME - this routine is suspect >+ # It blanks the Leader/00-05 and Leader/12-16 to >+ # force them to be recalculated correct when >+ # the $marc->as_usmarc() or $marc->as_xml() is called. >+ # But why is this necessary? It would be a serious bug >+ # in MARC::Record (definitely) and MARC::File::XML (arguably) >+ # if they are emitting incorrect leader values. >+ my $marc = shift; >+ >+ my $leader = $marc->leader; >+ substr($leader, 0, 5) = ' '; >+ substr($leader, 10, 7) = '22 '; >+ $marc->leader(substr($leader, 0, 24)); >+} >+ >+sub fix_biblio_ids { >+ # FIXME - it is essential to ensure that the biblionumber is present, >+ # otherwise, Zebra will choke on the record. However, this >+ # logic belongs in the relevant C4::Biblio APIs. >+ my $dbh = shift; >+ my $marc = shift; >+ my $biblionumber = shift; >+ my $biblioitemnumber; >+ if (@_) { >+ $biblioitemnumber = shift; >+ } else { >+ my $sth = $dbh->prepare( >+ "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); >+ $sth->execute($biblionumber); >+ ($biblioitemnumber) = $sth->fetchrow_array; >+ $sth->finish; >+ unless ($biblioitemnumber) { >+ warn "failed to get biblioitemnumber for biblio $biblionumber"; >+ return 0; >+ } >+ } >+ >+ # FIXME - this is cheating on two levels >+ # 1. C4::Biblio::_koha_marc_update_bib_ids is meant to be an internal function >+ # 2. Making sure that the biblionumber and biblioitemnumber are correct and >+ # present in the MARC::Record object ought to be part of GetMarcBiblio. >+ # >+ # On the other hand, this better for now than what rebuild_zebra.pl used to >+ # do, which was duplicate the code for inserting the biblionumber >+ # and biblioitemnumber >+ C4::Biblio::_koha_marc_update_bib_ids($marc, '', $biblionumber, $biblioitemnumber); >+ >+ return 1; >+} >+ >+sub fix_authority_id { >+ # FIXME - as with fix_biblio_ids, the authid must be present >+ # for Zebra's sake. However, this really belongs >+ # in C4::AuthoritiesMarc. >+ my ($marc, $authid) = @_; >+ unless ($marc->field('001') and $marc->field('001')->data() eq $authid){ >+ $marc->delete_field($marc->field('001')); >+ $marc->insert_fields_ordered(MARC::Field->new('001',$authid)); >+ } >+} >+ >+sub fix_unimarc_100 { >+ # FIXME - again, if this is necessary, it belongs in C4::AuthoritiesMarc. >+ my $marc = shift; >+ >+ my $string; >+ if ( length($marc->subfield( 100, "a" )) == 35 ) { >+ $string = $marc->subfield( 100, "a" ); >+ my $f100 = $marc->field(100); >+ $marc->delete_field($f100); >+ } >+ else { >+ $string = POSIX::strftime( "%Y%m%d", localtime ); >+ $string =~ s/\-//g; >+ $string = sprintf( "%-*s", 35, $string ); >+ } >+ substr( $string, 22, 6, "frey50" ); >+ unless ( length($marc->subfield( 100, "a" )) == 35 ) { >+ $marc->delete_field($marc->field(100)); >+ $marc->insert_grouped_field(MARC::Field->new( 100, "", "", "a" => $string )); >+ } >+} >+ > # given a ZOOM::Exception or > # ZOOM::Connection object, generate > # a human-reaable error message >-- >1.5.6.5 >
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 5717
: 3099