From 771a0b274ff023d5b5cd4308901ad9c84c116a6d 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 --- C4/Acquisition.pm | 26 ++++++++++++++------------ 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 | 6 ++++-- 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 | 6 ++++-- 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, 131 insertions(+), 97 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index c113c16..8a32239 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -287,17 +287,18 @@ sub GetBasketAsCSV { my @rows; 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'}, @@ -355,16 +356,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 ef2e432..5ee6d40 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3710,12 +3710,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 } @@ -3723,7 +3724,7 @@ sub UpdateTotalIssues { if (defined $value) { $totalissues = $value; } else { - $totalissues = $data->{'totalissues'} + $increase; + $totalissues = $biblioitem->totalissues + $increase; } my $field = $record->field($totalissuestag); @@ -3735,7 +3736,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 af5acce..cff738f 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1832,8 +1832,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 = GetItemIssue($itemnumber); if ($issue and $issue->{borrowernumber}) { diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index e5f29c7..5ecf211 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -678,8 +678,8 @@ sub CreatePicklistFromItemMap { my $firstname = $borrower->{'firstname'}; my $phone = $borrower->{'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 c078af1..a07b597 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; @@ -468,7 +469,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 $borrower = C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); # If an item is damaged and we don't allow holds on damaged items, we can stop right here @@ -478,7 +479,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 5512633..6da6f10 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 9ca84e9..3913c05 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -55,6 +55,7 @@ use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsBy use C4::Members qw/GetMember/; use Koha::EDI qw/create_edi_order get_edifact_ean/; +use Koha::Biblioitems; use Koha::Acquisition::Booksellers; our $input=new CGI; @@ -173,7 +174,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; my $itemtypes = GetItemTypes(); #FIXME DELETE ME @@ -195,7 +196,7 @@ sub printbasketgrouppdf{ } } - $ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? $itemtypes->{$bib->{itemtype}}->{description} : undef; + $ord->{itemtype} = ( $ord->{itemtype} and $biblioitem->itemtype ) ? $itemtypes->{$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 79736a6..7c8c271 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; @@ -55,8 +57,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 07924c8..45401a5 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 34d2b52..631a836 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 e9fad46..b185c04 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 3c9c2c2..ccd5d52 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -57,6 +57,8 @@ use C4::Members; use C4::Acquisition; use C4::Koha; use List::MoreUtils qw( any uniq ); + +use Koha::Biblios; use Koha::RecordProcessor; my $query = new CGI; @@ -89,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', @@ -113,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 9227fa0..f4b223c 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; @@ -141,12 +142,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 a7e643c..ba09490 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -47,6 +47,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::Virtualshelves; @@ -430,22 +432,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 e304066..cd26d20 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -32,6 +32,8 @@ use C4::Context; use C4::Members; use C4::Overdues; use C4::Debug; + +use Koha::Biblios; use Koha::DateUtils; use Koha::Libraries; use Koha::Patrons; @@ -518,7 +520,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 f8e86ba..39af047 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 a84e9d3..319a2c5 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 f85a833..57c437d 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 ) = GetMember( borrowernumber => $result->{borrowernumber} ); @@ -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 665d6b6..873a9c5 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 a022c99..4295f58 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::Holds; use Koha::Libraries; @@ -211,7 +213,7 @@ foreach my $biblionumber (@biblionumbers) { my %biblioloopiter = (); - my $dat = GetBiblioData($biblionumber); + my $biblio = Koha::Biblios->find( $biblionumber ); my $canReserve = CanBookBeReserved( $borrowerinfo->{borrowernumber}, $biblionumber ); $canReserve //= ''; @@ -372,11 +374,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 $issues= GetItemIssue($itemnumber); @@ -602,8 +604,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, ); @@ -612,7 +614,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 452b54c..b403d3f 100755 --- a/reviews/reviewswaiting.pl +++ b/reviews/reviewswaiting.pl @@ -23,6 +23,8 @@ use C4::Output; use C4::Context; use C4::Members; use C4::Biblio; + +use Koha::Biblios; use Koha::Reviews; my $query = new CGI; @@ -69,9 +71,9 @@ my $reviews = Koha::Reviews->search( foreach ( @$reviews ) { my $borrowernumber = $_->{borrowernumber}; my $borrowerData = GetMember('borrowernumber' => $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} = $borrowerData->{'surname'}; $_->{firstname} = $borrowerData->{'firstname'}; } diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 2bff94b..1f5c775 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 f66b650..690ad08 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 Carp; @@ -180,10 +181,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 2920da9..31f2da9 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -563,11 +563,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 ca98765..e39cd9e 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -35,6 +35,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; @@ -337,9 +339,9 @@ if ( $compareinv2barcd ) { } for my $item ( @items_with_problems ) { - 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; } # If a barcode file is given, we want to show problems, else all items diff --git a/tools/showdiffmarc.pl b/tools/showdiffmarc.pl index ec0f735..5ccb497 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 6e058e9..5d8b137 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; @@ -184,12 +185,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.9.3