X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=Koha%2FBiblioUtils.pm;h=cb7baed0dbd44341cd24ac4ab40a0e8e0260fcab;hb=cc58ca2a3cc71d2af6b2342979ec310e89fec3a6;hp=1ece4a8317b62f09a88adbac52c4662e67be2fa3;hpb=9d6d641d1f8b77271800f43bc027b651f9aea52b;p=koha-ffzg.git diff --git a/Koha/BiblioUtils.pm b/Koha/BiblioUtils.pm index 1ece4a8317..cb7baed0db 100644 --- a/Koha/BiblioUtils.pm +++ b/Koha/BiblioUtils.pm @@ -27,12 +27,9 @@ Koha::BiblioUtils - contains fundamental biblio-related functions This contains functions for normal operations on biblio records. -Note: really, C4::Biblio does the main functions, but the Koha namespace is -the new thing that should be used. - =cut -use C4::Biblio; +use Koha::Biblios; use Koha::MetadataIterator; use Koha::Database; use Modern::Perl; @@ -123,7 +120,7 @@ records instead of all. =cut sub get_all_biblios_iterator { - my ($self, %options) = @_; + my ($class, %options) = @_; my $search_terms = {}; my ($slice_modulo, $slice_count); @@ -140,8 +137,7 @@ sub get_all_biblios_iterator { my $database = Koha::Database->new(); my $schema = $database->schema(); - my $rs = - $schema->resultset('Biblio')->search( + my $rs = Koha::Biblios->search( $search_terms, $search_options ); my $next_func = sub { @@ -149,14 +145,12 @@ sub get_all_biblios_iterator { while (1) { my $row = $rs->next(); return if !$row; - my $marc = C4::Biblio::GetMarcBiblio({ - biblionumber => $row->biblionumber, - embed_items => 1 }); my $next = eval { - __PACKAGE__->new($marc, $row->biblionumber); + my $marc = $row->metadata->record({ embed_items => 1 }); + $class->new($marc, $row->biblionumber); }; if ($@) { - warn "Something went wrong reading record for biblio $row->biblionumber: $@\n"; + warn sprintf "Something went wrong reading record for biblio %s: %s\n", $row->biblionumber, $@; next; } return $next; @@ -188,9 +182,9 @@ If set to true, item data is embedded in the record. Default is to not do this. sub get_marc_biblio { my ($class, $bibnum, %options) = @_; - return C4::Biblio::GetMarcBiblio({ - biblionumber => $bibnum, - embed_items => ($options{item_data} ? 1 : 0 ) }); + my $record = Koha::Biblios->find($bibnum) + ->metadata->record( { $options{item_data} ? ( embed_items => 1 ) : () } ); + return $record; } 1;