From 3949b628f4bbc05f6214d1cf547d3cc54d6cf32f Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Thu, 1 Oct 2015 15:53:44 +1300 Subject: [PATCH] Bug 12478: fix errors from rebase and new upstream version Signed-off-by: Nick Clemens Signed-off-by: Jesse Weaver Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- Koha/BiblioUtils.pm | 30 ++++++++++++++------- misc/search_tools/rebuild_elastic_search.pl | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Koha/BiblioUtils.pm b/Koha/BiblioUtils.pm index a136132c57..27dbccd590 100644 --- a/Koha/BiblioUtils.pm +++ b/Koha/BiblioUtils.pm @@ -1,4 +1,4 @@ -package Koha::BiblioUtilsUtils; +package Koha::BiblioUtils; # This contains functions to do with managing biblio records. @@ -27,19 +27,21 @@ Koha::BiblioUtils - contains fundamental biblio-related functions This contains functions for normal operations on biblio records. -Note: really, C4::BiblioUtils does the main functions, but the Koha namespace is +Note: really, C4::Biblio does the main functions, but the Koha namespace is the new thing that should be used. =cut -use C4::BiblioUtils; # EmbedItemsInMarcBiblio +use C4::Biblio; # EmbedItemsInMarcBiblio use Koha::MetadataIterator; use Koha::Database; use Modern::Perl; +use Data::Dumper; # TODO remove + use base qw(Koha::MetadataRecord); -__PACKAGE__->mk_accessors(qw( record schema idnumber datatype )); +__PACKAGE__->mk_accessors(qw( record schema id datatype )); =head1 FUNCTIONS @@ -61,7 +63,7 @@ sub new { { 'record' => $record, 'schema' => lc C4::Context->preference("marcflavour"), - 'idnumber' => $biblionumber, + 'id' => $biblionumber, 'datatype' => 'biblio', } ); @@ -115,10 +117,20 @@ sub get_all_biblios_iterator { $schema->resultset('Biblio')->search( {}, { columns => [qw/ biblionumber /] } ); my $next_func = sub { - my $row = $rs->next(); - return undef if !$row; - my $marc = C4::Biblio::GetMarcBiblio( $row->biblionumber, 1 ); - return __PACKAGE__->new($marc, $row->biblionumber); + # Warn and skip bad records, otherwise we break the loop + while (1) { + my $row = $rs->next(); + return undef if !$row; + my $marc = C4::Biblio::GetMarcBiblio( $row->biblionumber, 1 ); + my $next = eval { + __PACKAGE__->new($marc, $row->biblionumber); + }; + if ($@) { + warn "Something went wrong reading record for biblio $row->biblionumber: $@\n"; + next; + } + return $next; + } }; return Koha::MetadataIterator->new($next_func); } diff --git a/misc/search_tools/rebuild_elastic_search.pl b/misc/search_tools/rebuild_elastic_search.pl index e8eabc7c5e..8d19dd98da 100755 --- a/misc/search_tools/rebuild_elastic_search.pl +++ b/misc/search_tools/rebuild_elastic_search.pl @@ -168,7 +168,7 @@ sub do_reindex { my $commit_count = $commit; my ( @id_buffer, @commit_buffer ); while ( my $record = $next->() ) { - my $id = $record->idnumber; + my $id = $record->id; my $record = $record->record; _log( 1, "$id\n" ); $count++; -- 2.39.5