Bugzilla – Attachment 4318 Details for
Bug 6433
rebuild_zebra.pl does not handle MARC::Record exceptions gracefully
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Signed-off patch
0001-SIGNED-OFF-bug_6433-exception-handling.patch (text/plain), 3.50 KB, created by
Magnus Enger
on 2011-05-31 12:08:44 UTC
(
hide
)
Description:
Signed-off patch
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2011-05-31 12:08:44 UTC
Size:
3.50 KB
patch
obsolete
>From 396a81a3f10ec5c1782f5fb04ecc7857d070124e Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Srdjan=20Jankovi=C4=87?= <srdjan@catalyst.net.nz> >Date: Tue, 31 May 2011 15:18:21 +1200 >Subject: [PATCH] [SIGNED-OFF] bug_6433: exception handling > > >Signed-off-by: Magnus Enger <magnus@enger.priv.no> >--- > C4/Biblio.pm | 4 ++++ > misc/migration_tools/rebuild_zebra.pl | 25 +++++++++++++++++-------- > 2 files changed, 21 insertions(+), 8 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index c9590c2..958a479 100755 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -21,6 +21,7 @@ package C4::Biblio; > > use strict; > use warnings; >+use Carp; > > # use utf8; > use MARC::Record; >@@ -294,6 +295,8 @@ and biblionumber data for indexing. > > sub ModBiblio { > my ( $record, $biblionumber, $frameworkcode ) = @_; >+ croak "No record" unless $record; >+ > if ( C4::Context->preference("CataloguingLog") ) { > my $newrecord = GetMarcBiblio($biblionumber); > logaction( "CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>" . $newrecord->as_formatted ); >@@ -2665,6 +2668,7 @@ per the bib's MARC framework. > > sub EmbedItemsInMarcBiblio { > my ($marc, $biblionumber) = @_; >+ croak "No MARC record" unless $marc; > > my $frameworkcode = GetFrameworkCode($biblionumber); > _strip_item_fields($marc, $frameworkcode); >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index 5be01cf..6710224 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -351,8 +351,13 @@ sub export_marc_records_from_sth { > # strung together with no single root element. zebraidx doesn't seem > # to care, though, at least if you're using the GRS-1 filter. It does > # care if you're using the DOM filter, which requires valid XML file(s). >- print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc(); >- $num_exported++; >+ eval { >+ print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc(); >+ $num_exported++; >+ }; >+ if ($@) { >+ warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML"); >+ } > } > } > print "\nRecords exported: $num_exported\n" if ( $verbose_logging ); >@@ -449,15 +454,19 @@ sub get_raw_marc_record { > $fetch_sth->execute($record_number); > if (my ($blob) = $fetch_sth->fetchrow_array) { > $marc = MARC::Record->new_from_usmarc($blob); >- $fetch_sth->finish(); >- } else { >- return; # failure to find a bib is not a problem - >- # a delete could have been done before >- # trying to process a record update >+ unless ($marc) { >+ warn "error creating MARC::Record from $blob"; >+ } > } >+ # failure to find a bib is not a problem - >+ # a delete could have been done before >+ # trying to process a record update >+ >+ $fetch_sth->finish(); >+ return unless $marc; > } else { > eval { $marc = GetMarcBiblio($record_number); }; >- if ($@) { >+ if ($@ || !$marc) { > # here we do warn since catching an exception > # means that the bib was found but failed > # to be parsed >-- >1.7.4.1 >
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 6433
:
4316
| 4318