From bd3b1c1a33e4bb14bbcd10a0fcf871b39362430d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 13 Mar 2017 17:44:25 -0300 Subject: [PATCH] Bug 18262: Koha::Biblio - Remove GetBiblioData - part 1 Most of the time C4::Biblio::GetBiblioData is used to retrieve the title and/or the author of a bibliographic record. This patch replaces the easy occurrences of GetBiblioData, the ones where the 2 joins are needed, but only data from biblio and biblioitems table are. Test plan: It will be hard to test everything, I'd suggest a QAer to review this patch and confirm that the difference occurrences of GetBiblioData have been correctly replaced by calling Koha::Biblios->find or $biblio->bibioitem Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/Acquisition.pm | 41 +++++++++++--------------- C4/Biblio.pm | 11 +++---- C4/Circulation.pm | 4 +-- C4/HoldsQueue.pm | 4 +-- C4/Reserves.pm | 5 ++-- C4/XISBN.pm | 9 +++--- acqui/basketgroup.pl | 5 ++-- cataloguing/moveitem.pl | 6 ++-- labels/label-item-search.pl | 1 - misc/migration_tools/bulkmarcimport.pl | 5 +++- misc/migration_tools/import_lexile.pl | 16 +++++----- opac/opac-MARCdetail.pl | 5 ++-- opac/opac-addbybiblionumber.pl | 7 +++-- opac/opac-detail.pl | 14 +++++---- opac/opac-reserve.pl | 4 ++- opac/opac-review.pl | 6 ++-- opac/opac-search.pl | 2 +- opac/opac-showreviews.pl | 21 ++++++------- opac/opac-tags.pl | 8 +++-- reserve/request.pl | 20 +++++++------ reviews/reviewswaiting.pl | 5 ++-- serials/serials-edit.pl | 4 +-- serials/subscription-add.pl | 7 +++-- tools/batchMod.pl | 10 +++---- tools/inventory.pl | 8 +++-- tools/showdiffmarc.pl | 6 ++-- virtualshelves/addbybiblionumber.pl | 7 +++-- 27 files changed, 133 insertions(+), 108 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 346fb4546c..ebbe44b106 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -314,20 +314,13 @@ sub GetBasketAsCSV { } for my $order (@orders) { my @row; - my $bd = GetBiblioData( $order->{'biblionumber'} ); - my @biblioitems = GetBiblioItemByBiblioNumber( $order->{'biblionumber'}); - for my $biblioitem (@biblioitems) { - if ( $biblioitem->{isbn} - and $order->{isbn} - and $biblioitem->{isbn} eq $order->{isbn} ) - { - $order = { %$order, %$biblioitem }; - } - } + my $biblio = Koha::Biblios->find( $order->{biblionumber} ); + my $biblioitem = $biblio->biblioitem; + $order = { %$order, %{ $biblioitem->unblessed } }; if ($contract) { $order = {%$order, %$contract}; } - $order = {%$order, %$basket, %$bd}; + $order = {%$order, %$basket, %{ $biblio->unblessed }}; for my $field (@fields) { push @row, $order->{$field}; } @@ -343,17 +336,18 @@ sub GetBasketAsCSV { } else { foreach my $order (@orders) { - my $bd = GetBiblioData( $order->{'biblionumber'} ); + my $biblio = Koha::Biblios->find( $order->{biblionumber} ); + my $biblioitem = $biblio->biblioitem; my $row = { contractname => $contract->{'contractname'}, ordernumber => $order->{'ordernumber'}, entrydate => $order->{'entrydate'}, isbn => $order->{'isbn'}, - author => $bd->{'author'}, - title => $bd->{'title'}, - publicationyear => $bd->{'publicationyear'}, - publishercode => $bd->{'publishercode'}, - collectiontitle => $bd->{'collectiontitle'}, + author => $biblio->author, + title => $biblio->title, + publicationyear => $biblioitem->publicationyear, + publishercode => $biblioitem->publishercode, + collectiontitle => $biblioitem->collectiontitle, notes => $order->{'order_vendornote'}, quantity => $order->{'quantity'}, rrp => $order->{'rrp'}, @@ -412,16 +406,17 @@ sub GetBasketGroupAsCSV { my $basketgroup = GetBasketgroup( $$basket{basketgroupid} ); foreach my $order (@orders) { - my $bd = GetBiblioData( $order->{'biblionumber'} ); + my $biblio = Koha::Biblios->find( $order->{biblionumber} ); + my $biblioitem = $biblio->biblioitem; my $row = { clientnumber => $bookseller->accountnumber, basketname => $basket->{basketname}, ordernumber => $order->{ordernumber}, - author => $bd->{author}, - title => $bd->{title}, - publishercode => $bd->{publishercode}, - publicationyear => $bd->{publicationyear}, - collectiontitle => $bd->{collectiontitle}, + author => $biblio->author, + title => $biblio->title, + publishercode => $biblioitem->publishercode, + publicationyear => $biblioitem->publicationyear, + collectiontitle => $biblioitem->collectiontitle, isbn => $order->{isbn}, quantity => $order->{quantity}, rrp_tax_included => $order->{rrp_tax_included}, diff --git a/C4/Biblio.pm b/C4/Biblio.pm index f55a38336f..0ee689d70a 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3586,12 +3586,13 @@ sub UpdateTotalIssues { carp "UpdateTotalIssues could not get biblio record"; return; } - my $data = GetBiblioData($biblionumber); - unless ($data) { + my $biblio = Koha::Biblios->find( $biblionumber ); + unless ($biblio) { carp "UpdateTotalIssues could not get datas of biblio"; return; } - my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'}); + my $biblioitem = $biblio->biblioitem; + my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $biblio->frameworkcode); unless ($totalissuestag) { return 1; # There is nothing to do } @@ -3599,7 +3600,7 @@ sub UpdateTotalIssues { if (defined $value) { $totalissues = $value; } else { - $totalissues = $data->{'totalissues'} + $increase; + $totalissues = $biblioitem->totalissues + $increase; } my $field = $record->field($totalissuestag); @@ -3611,7 +3612,7 @@ sub UpdateTotalIssues { $record->insert_grouped_field($field); } - return ModBiblio($record, $biblionumber, $data->{'frameworkcode'}); + return ModBiblio($record, $biblionumber, $biblio->frameworkcode); } =head2 RemoveAllNsb diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0c5585aa2a..cb60da3ed9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1822,8 +1822,8 @@ sub AddReturn { my $itemnumber = $item->{ itemnumber }; my $item_level_itypes = C4::Context->preference("item-level_itypes"); - my $biblio = $item_level_itypes ? undef : GetBiblioData( $item->{ biblionumber } ); # don't get bib data unless we need it - my $itemtype = $item_level_itypes ? $item->{itype} : $biblio->{itemtype}; + my $biblio = $item_level_itypes ? undef : Koha::Biblios->find( $item->{ biblionumber } ); # don't get bib data unless we need it + my $itemtype = $item_level_itypes ? $item->{itype} : $biblio->biblioitem->itemtype; my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); if ( $issue ) { diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 218260e0fd..1e893fa5b7 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -684,8 +684,8 @@ sub CreatePicklistFromItemMap { my $firstname = $patron->firstname; my $phone = $patron->phone; - my $bib = GetBiblioData($biblionumber); - my $title = $bib->{title}; + my $biblio = Koha::Biblios->find( $biblionumber ); + my $title = $biblio->title; $sth_load->execute($biblionumber, $itemnumber, $barcode, $surname, $firstname, $phone, $borrowernumber, $cardnumber, $reservedate, $title, $itemcallnumber, diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 6d52d6d10b..50982306a1 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -36,6 +36,7 @@ use C4::Members qw(); use C4::Letters; use C4::Log; +use Koha::Biblios; use Koha::DateUtils; use Koha::Calendar; use Koha::Database; @@ -330,7 +331,7 @@ sub CanItemBeReserved { # we retrieve borrowers and items informations # # item->{itype} will come for biblioitems if necessery my $item = GetItem($itemnumber); - my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} ); + my $biblio = Koha::Biblios->find( $item->{biblionumber} ); my $patron = Koha::Patrons->find( $borrowernumber ); my $borrower = $patron->unblessed; @@ -341,7 +342,7 @@ sub CanItemBeReserved { # Check for the age restriction my ( $ageRestriction, $daysToAgeRestriction ) = - C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); + C4::Circulation::GetAgeRestriction( $biblio->biblioitem->agerestriction, $borrower ); return 'ageRestricted' if $daysToAgeRestriction && $daysToAgeRestriction > 0; # Check that the patron doesn't have an item level hold on this item already diff --git a/C4/XISBN.pm b/C4/XISBN.pm index 55126334b3..6da6f10d9b 100644 --- a/C4/XISBN.pm +++ b/C4/XISBN.pm @@ -26,6 +26,7 @@ use C4::External::Syndetics qw(get_syndetics_editions); use LWP::UserAgent; use HTTP::Request::Common; +use Koha::Biblios; use Koha::SearchEngine; use Koha::SearchEngine::Search; @@ -74,10 +75,10 @@ sub _get_biblio_from_xisbn { my $biblionumber = C4::Biblio::get_koha_field_from_marc('biblio', 'biblionumber', $record, ''); return unless $biblionumber; - my $xbiblio = GetBiblioData($biblionumber); - return unless $xbiblio; - $xbiblio->{normalized_isbn} = GetNormalizedISBN($xbiblio->{isbn}); - return $xbiblio; + my $biblio = Koha::Biblios->find( $biblionumber ); + return unless $biblio; + $biblio->{normalized_isbn} = GetNormalizedISBN($biblio->biblioitem->isbn); + return $biblio; } =head1 get_xisbns($isbn); diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 333e542e3b..e1a16fdae0 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -54,6 +54,7 @@ use CGI qw ( -utf8 ); use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/; use Koha::EDI qw/create_edi_order get_edifact_ean/; +use Koha::Biblioitems; use Koha::Acquisition::Booksellers; use Koha::ItemTypes; use Koha::Patrons; @@ -174,7 +175,7 @@ sub printbasketgrouppdf{ $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity}; $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity}; - my $bib = GetBiblioData($ord->{biblionumber}); + my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next; #FIXME DELETE ME # 0 1 2 3 4 5 6 7 8 9 @@ -195,7 +196,7 @@ sub printbasketgrouppdf{ } } - $ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? Koha::ItemTypes->find( $bib->{itemtype} )->description : undef; + $ord->{itemtype} = ( $ord->{itemtype} and $biblioitem->itemtype ) ? Koha::ItemTypes->find( $biblioitem->itemtype )->description : undef; $ord->{en} = $en ? $en : undef; $ord->{edition} = $edition ? $edition : undef; diff --git a/cataloguing/moveitem.pl b/cataloguing/moveitem.pl index 37c9a5e41e..7805da4dad 100755 --- a/cataloguing/moveitem.pl +++ b/cataloguing/moveitem.pl @@ -31,6 +31,8 @@ use C4::Koha; use C4::ClassSource; use C4::Acquisition qw/GetOrderFromItemnumber ModOrder GetOrder/; +use Koha::Biblios; + use Date::Calc qw(Today); use MARC::File::XML; @@ -58,8 +60,8 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( -my $biblio = GetBiblioData($biblionumber); -$template->param(bibliotitle => $biblio->{'title'}); +my $biblio = Koha::Biblios->find( $biblionumber ); +$template->param(bibliotitle => $biblio->title); $template->param(biblionumber => $biblionumber); # If we already have the barcode of the item to move and the biblionumber to move the item to diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index ddc0bf88dd..53b7d46755 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -128,7 +128,6 @@ if ($show_results) { my @items =(); # This code needs to be refactored using these subs... #my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' ); - #my $dat = &GetBiblioData( $biblio->{biblionumber} ); for ( my $i = 0 ; $i < $hits ; $i++ ) { my @row_data= (); #DEBUG Notes: Decode the MARC record from each resulting MARC record... diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index dc2cae4182..29ef0fbe0f 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -31,6 +31,7 @@ use Getopt::Long; use IO::File; use Pod::Usage; +use Koha::Biblios; use Koha::SearchEngine; use Koha::SearchEngine::Search; @@ -417,7 +418,9 @@ RECORD: while ( ) { } # create biblio, unless we already have it ( either match or isbn ) if ($biblionumber) { - eval{$biblioitemnumber=GetBiblioData($biblionumber)->{biblioitemnumber};}; + eval{ + $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber; + }; if ($update) { eval { ( $biblionumber, $biblioitemnumber ) = ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) }; if ($@) { diff --git a/misc/migration_tools/import_lexile.pl b/misc/migration_tools/import_lexile.pl index e9fad46503..b185c0489b 100755 --- a/misc/migration_tools/import_lexile.pl +++ b/misc/migration_tools/import_lexile.pl @@ -34,6 +34,8 @@ use Text::CSV; use C4::Context; use C4::Biblio; use C4::Koha qw( GetVariationsOfISBN ); + +use Koha::Biblios; use Koha::Database; binmode STDOUT, ':encoding(UTF-8)'; @@ -156,13 +158,13 @@ while ( my $row = $csv->getline_hr($fh) ) { say "Found matching record! Biblionumber: $biblionumber"; if ( $verbose > 2 ) { - my $biblio = GetBiblioData($biblionumber); - say "Title from record: " . $biblio->{title} - if ( $biblio->{title} ); - say "Author from record: " . $biblio->{author} - if ( $biblio->{author} ); - say "ISBN from record: " . $biblio->{isbn} - if ( $biblio->{isbn} ); + my $biblio = Koha::Biblios->find( $biblionumber ); + say "Title from record: " . $biblio->title + if $biblio->title; + say "Author from record: " . $biblio->author + if $biblio->author; + say "ISBN from record: " . $biblio->biblioitem->isbn + if $biblio->biblioitem->isbn; } say "Title: " . $row->{Title}; say "Author: " . $row->{Author}; diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 115e8fd9e8..a899e92e82 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -57,6 +57,7 @@ use C4::Members; use C4::Acquisition; use C4::Koha; use List::MoreUtils qw( any uniq ); +use Koha::Biblios; use Koha::Patrons; use Koha::RecordProcessor; @@ -90,7 +91,7 @@ if (scalar @all_items >= 1) { my $framework = &GetFrameworkCode( $biblionumber ); my $tagslib = &GetMarcStructure( 0, $framework ); my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework); -my $biblio = GetBiblioData($biblionumber); +my $biblio = Koha::Biblios->find( $biblionumber ); my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy', @@ -114,7 +115,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework); $template->param( - bibliotitle => $biblio->{title}, + bibliotitle => $biblio->title, ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index ddebf4fabf..ddc6778502 100755 --- a/opac/opac-addbybiblionumber.pl +++ b/opac/opac-addbybiblionumber.pl @@ -25,6 +25,7 @@ use C4::Biblio; use C4::Output; use C4::Auth; +use Koha::Biblios; use Koha::Virtualshelves; my $query = new CGI; @@ -142,12 +143,12 @@ if ($newvirtualshelf) { if ($authorized) { for my $biblionumber (@biblionumbers) { - my $data = GetBiblioData($biblionumber); + my $biblio = Koha::Biblios->find( $biblionumber ); push( @biblios, { biblionumber => $biblionumber, - title => $data->{'title'}, - author => $data->{'author'}, + title => $biblio->title, + author => $biblio->author, } ); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index ed8a5d56aa..ae89f825d7 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -48,6 +48,8 @@ use C4::Images; use Koha::DateUtils; use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); + +use Koha::Biblios; use Koha::RecordProcessor; use Koha::AuthorisedValues; use Koha::Biblios; @@ -434,22 +436,22 @@ if ($session->param('busc')) { $numberBiblioPaging = $paging{'previous'}->{biblionumber}; if ($numberBiblioPaging) { $template->param( 'previousBiblionumber' => $numberBiblioPaging ); - $dataBiblioPaging = GetBiblioData($numberBiblioPaging); - $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging); + $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging ); + $template->param('previousTitle' => $dataBiblioPaging->title) if $dataBiblioPaging; } # Next biblio $numberBiblioPaging = $paging{'next'}->{biblionumber}; if ($numberBiblioPaging) { $template->param( 'nextBiblionumber' => $numberBiblioPaging ); - $dataBiblioPaging = GetBiblioData($numberBiblioPaging); - $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging); + $dataBiblioPaging = Koha::Biblios->find( $numberBiblioPaging ); + $template->param('nextTitle' => $dataBiblioPaging->title) if $dataBiblioPaging; } # Partial list of biblio results my @listResults; for (my $j = 0; $j < @arrBiblios; $j++) { next unless ($arrBiblios[$j]); - $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber); - push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->{title}, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->{author})?$dataBiblioPaging->{author}:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]}; + $dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber); + push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->title, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->author)?$dataBiblioPaging->author:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]}; } $template->param('listResults' => \@listResults) if (@listResults); $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index bf50f366a3..53124493ab 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -32,7 +32,9 @@ use C4::Context; use C4::Members; use C4::Overdues; use C4::Debug; + use Koha::AuthorisedValues; +use Koha::Biblios; use Koha::DateUtils; use Koha::Items; use Koha::ItemTypes; @@ -522,7 +524,7 @@ foreach my $biblioNum (@biblionumbers) { if ( $itemInfo->{biblionumber} ne $biblioNum ) { $biblioLoopIter{hostitemsflag} = 1; $itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; - $itemLoopIter->{hosttitle} = GetBiblioData( $itemInfo->{biblionumber} )->{title}; + $itemLoopIter->{hosttitle} = Koha::Biblios->find( $itemInfo->{biblionumber} )->title; } # If there is no loan, return and transfer, we show a checkbox. diff --git a/opac/opac-review.pl b/opac/opac-review.pl index f8e86bac13..39af047cfd 100755 --- a/opac/opac-review.pl +++ b/opac/opac-review.pl @@ -25,6 +25,8 @@ use C4::Output; use C4::Biblio; use C4::Scrubber; use C4::Debug; + +use Koha::Biblios; use Koha::DateUtils; use Koha::Review; use Koha::Reviews; @@ -45,7 +47,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( # FIXME: need to allow user to delete their own comment(s) my ( $clean, @errors, $savedreview ); -my $biblio = GetBiblioData($biblionumber); +my $biblio = Koha::Biblios->find( $biblionumber ); if( !$biblio ) { push @errors, { nobiblio => 1 }; @@ -101,7 +103,7 @@ $template->param( 'borrowernumber' => $borrowernumber, 'review' => $review, 'reviewid' => $reviewid || 0, - 'title' => $biblio->{'title'}, + 'title' => $biblio->title, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 145673230d..2272587b46 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -46,7 +46,7 @@ use C4::Auth qw(:DEFAULT get_session); use C4::Languages qw(getLanguages); use C4::Search; use C4::Search::History; -use C4::Biblio; # GetBiblioData +use C4::Biblio; # Unused here? use C4::Koha; use C4::Tags qw(get_tags); use C4::SocialData; diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index 99a7ed1c5d..84eba04b90 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -89,7 +89,8 @@ my $i = 0; my $latest_comment_date; for my $result (@$reviews){ my $biblionumber = $result->{biblionumber}; - my $bib = &GetBiblioData($biblionumber); + my $biblio = Koha::Biblios->find( $biblionumber ); + my $biblioitem = $biblio->biblioitem; my $record = GetMarcBiblio($biblionumber); my $frameworkcode = GetFrameworkCode($biblionumber); my $borr = Koha::Patrons->find( $result->{borrowernumber} )->unblessed; @@ -97,16 +98,16 @@ for my $result (@$reviews){ $result->{normalized_ean} = GetNormalizedEAN($record,$marcflavour); $result->{normalized_oclc} = GetNormalizedOCLCNumber($record,$marcflavour); $result->{normalized_isbn} = GetNormalizedISBN(undef,$record,$marcflavour); - $result->{title} = $bib->{'title'}; + $result->{title} = $biblio->title; $result->{subtitle} = GetRecordValue('subtitle', $record, $frameworkcode); - $result->{author} = $bib->{'author'}; - $result->{place} = $bib->{'place'}; - $result->{publishercode} = $bib->{'publishercode'}; - $result->{copyrightdate} = $bib->{'copyrightdate'}; - $result->{pages} = $bib->{'pages'}; - $result->{size} = $bib->{'size'}; - $result->{notes} = $bib->{'notes'}; - $result->{timestamp} = $bib->{'timestamp'}; + $result->{author} = $biblio->author; + $result->{place} = $biblioitem->place; + $result->{publishercode} = $biblioitem->publishercode; + $result->{copyrightdate} = $biblio->copyrightdate; + $result->{pages} = $biblioitem->pages; + $result->{size} = $biblioitem->size; + $result->{notes} = $biblioitem->notes; + $result->{timestamp} = $biblioitem->timestamp; $result->{borrtitle} = $borr->{'title'}; $result->{firstname} = $borr->{'firstname'}; $result->{surname} = $borr->{'surname'}; diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 665d6b6702..873a9c54d5 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -46,6 +46,8 @@ use C4::XSLT; use Data::Dumper; +use Koha::Biblios; + my %newtags = (); my @deltags = (); my %counts = (); @@ -229,11 +231,11 @@ if ($loggedinuser) { $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); my $my_approved_tags = get_approval_rows({ approved => 1 }); foreach my $tag (@$my_tags) { - my $biblio = GetBiblioData($tag->{biblionumber}); + my $biblio = Koha::Biblios->find( $tag->{biblionumber} ); my $record = &GetMarcBiblio( $tag->{biblionumber} ); $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) ); - $tag->{title} = $biblio->{title}; - $tag->{author} = $biblio->{author}; + $tag->{title} = $biblio->title; + $tag->{author} = $biblio->author; my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay'); my $lang = $xslfile ? C4::Languages::getlanguage() : undef; diff --git a/reserve/request.pl b/reserve/request.pl index 15ad54a164..7cda03dce2 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -42,6 +42,8 @@ use Koha::DateUtils; use C4::Utils::DataTables::Members; use C4::Members; use C4::Search; # enabled_staff_search_views + +use Koha::Biblios; use Koha::DateUtils; use Koha::Checkouts; use Koha::Holds; @@ -213,7 +215,7 @@ foreach my $biblionumber (@biblionumbers) { my %biblioloopiter = (); - my $dat = GetBiblioData($biblionumber); + my $biblio = Koha::Biblios->find( $biblionumber ); my $force_hold_level; if ( $patron ) { @@ -380,11 +382,11 @@ foreach my $biblionumber (@biblionumbers) { $item->{holdingbranch} = $item->{holdingbranch}; } - if($item->{biblionumber} ne $biblionumber){ - $item->{hostitemsflag}=1; - $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; - } - + if($item->{biblionumber} ne $biblionumber){ + $item->{hostitemsflag} = 1; + $item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title; + } + # if the item is currently on loan, we display its return date and # change the background color my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); @@ -612,8 +614,8 @@ foreach my $biblionumber (@biblionumbers) { date => $date, biblionumber => $biblionumber, findborrower => $findborrower, - title => $dat->{title}, - author => $dat->{author}, + title => $biblio->title, + author => $biblio->author, holdsview => 1, C4::Search::enabled_staff_search_views, ); @@ -622,7 +624,7 @@ foreach my $biblionumber (@biblionumbers) { } $biblioloopiter{biblionumber} = $biblionumber; - $biblioloopiter{title} = $dat->{title}; + $biblioloopiter{title} = $biblio->title; $biblioloopiter{rank} = $fixedRank; $biblioloopiter{reserveloop} = \@reserveloop; diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl index 26696645b5..528425290d 100755 --- a/reviews/reviewswaiting.pl +++ b/reviews/reviewswaiting.pl @@ -22,6 +22,7 @@ use C4::Auth; use C4::Output; use C4::Context; use C4::Biblio; +use Koha::Biblios; use Koha::Patrons; use Koha::Reviews; @@ -69,9 +70,9 @@ my $reviews = Koha::Reviews->search( foreach ( @$reviews ) { my $borrowernumber = $_->{borrowernumber}; my $patron = Koha::Patrons->find( $borrowernumber); - my $biblioData = GetBiblioData($_->{biblionumber}); + my $biblio = Koha::Biblios->find( $_->{biblionumber} ); # setting some borrower info into this hash - $_->{bibliotitle} = $biblioData->{'title'}; + $_->{bibliotitle} = $biblio->title; $_->{surname} = $patron->surname; $_->{firstname} = $patron->firstname; } diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 2bff94b66e..1f5c775ce8 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -164,7 +164,7 @@ foreach my $serialid (@serialids) { $processedserialid{$serialid} = 1; } } -my $biblio = GetBiblioData( $serialdatalist[0]->{'biblionumber'} ); +my $biblio = Koha::Biblios->find( $serialdatalist[0]->{biblionumber} ); my @newserialloop; my @subscriptionloop; @@ -425,7 +425,7 @@ $template->param( serialsadditems => $serialdatalist[0]->{'serialsadditems'}, callnumber => $serialdatalist[0]->{'callnumber'}, internalnotes => $serialdatalist[0]->{'internalnotes'}, - bibliotitle => $biblio->{'title'}, + bibliotitle => $biblio->title, biblionumber => $serialdatalist[0]->{'biblionumber'}, serialslist => \@serialdatalist, default_bib_view => $default_bib_view, diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index ce7f168e8b..c73b28d85b 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -31,6 +31,7 @@ use C4::Serials::Frequency; use C4::Serials::Numberpattern; use C4::Letters; use Koha::AdditionalField; +use Koha::Biblios; use Koha::DateUtils; use Koha::ItemTypes; use Carp; @@ -182,10 +183,10 @@ if ($op eq 'addsubscription') { my $new_biblionumber = $query->param('biblionumber_for_new_subscription'); if (defined $new_biblionumber) { - my $bib = GetBiblioData($new_biblionumber); - if (defined $bib) { + my $biblio = Koha::Biblios->find( $new_biblionumber ); + if (defined $biblio) { $template->param(bibnum => $new_biblionumber); - $template->param(bibliotitle => $bib->{title}); + $template->param(bibliotitle => $biblio->title); } } diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 1a216d7c76..b24ce2b329 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -576,11 +576,11 @@ sub BuildItemsData{ # grab title, author, and ISBN to identify bib that the item # belongs to in the display - my $biblio=GetBiblioData($$itemdata{biblionumber}); - $this_row{title} = $biblio->{title}; - $this_row{author} = $biblio->{author}; - $this_row{isbn} = $biblio->{isbn}; - $this_row{biblionumber} = $biblio->{biblionumber}; + my $biblio = Koha::Biblios->find( $itemdata->{biblionumber} ); + $this_row{title} = $biblio->title; + $this_row{author} = $biblio->author; + $this_row{isbn} = $biblio->biblioitem->isbn; + $this_row{biblionumber} = $biblio->biblionumber; if (%this_row) { push(@big_array, \%this_row); diff --git a/tools/inventory.pl b/tools/inventory.pl index 1ee40a1014..d6f9e4a907 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -34,6 +34,8 @@ use C4::Koha; use C4::Circulation; use C4::Reports::Guided; #_get_column_defs use C4::Charset; + +use Koha::Biblios; use Koha::DateUtils; use Koha::AuthorisedValues; use Koha::BiblioFrameworks; @@ -311,9 +313,9 @@ my $loop = $uploadbarcodes ? [ map { $results->{$_} } keys %$results ] : $inventorylist // []; for my $item ( @$loop ) { - my $biblio = C4::Biblio::GetBiblioData($item->{biblionumber}); - $item->{title} = $biblio->{title}; - $item->{author} = $biblio->{author}; + my $biblio = Koha::Biblios->find( $item->{biblionumber} ); + $item->{title} = $biblio->title; + $item->{author} = $biblio->author; } $template->param( diff --git a/tools/showdiffmarc.pl b/tools/showdiffmarc.pl index ec0f735181..5ccb497b40 100755 --- a/tools/showdiffmarc.pl +++ b/tools/showdiffmarc.pl @@ -31,6 +31,8 @@ use C4::Auth; use C4::Biblio; use C4::ImportBatch; +use Koha::Biblios; + # Input params my $input = new CGI; my $biblionumber = $input->param('id'); @@ -60,8 +62,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( $recordBiblionumber = GetMarcBiblio($biblionumber, 'embed_items'); if( $recordBiblionumber ) { $formatted1 = $recordBiblionumber->as_formatted; - my $data = GetBiblioData($biblionumber); - $biblioTitle = $data->{title}; + my $biblio = Koha::Biblios->find( $biblionumber ); + $biblioTitle = $biblio->title; } else { $errorFormatted1 = 1; } diff --git a/virtualshelves/addbybiblionumber.pl b/virtualshelves/addbybiblionumber.pl index 210e1531e1..a60c88fd53 100755 --- a/virtualshelves/addbybiblionumber.pl +++ b/virtualshelves/addbybiblionumber.pl @@ -63,6 +63,7 @@ use C4::Biblio; use C4::Output; use C4::Auth; +use Koha::Biblios; use Koha::Virtualshelves; my $query = new CGI; @@ -185,12 +186,12 @@ if ($newvirtualshelf) { my @biblios; for my $biblionumber (@biblionumbers) { - my $data = GetBiblioData($biblionumber); + my $biblio = Koha::Biblios->find( $biblionumber ); push( @biblios, { biblionumber => $biblionumber, - title => $data->{'title'}, - author => $data->{'author'}, + title => $biblio->title, + author => $biblio->author, } ); } -- 2.39.5