Browse Source

Bug 19040: Refactor GetMarcBiblio parameters

Change parameters to a hashref.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Looks good to me.
Two calls in migration_tools/22_to_30 still in old style.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
17.11.x
Mark Tompsett 4 years ago
committed by Jonathan Druart
parent
commit
d5986c9b97
  1. 2
      C4/AuthoritiesMarc.pm
  2. 34
      C4/Biblio.pm
  3. 2
      C4/HoldsQueue.pm
  4. 4
      C4/ILSDI/Services.pm
  5. 2
      C4/Items.pm
  6. 4
      C4/Labels/Label.pm
  7. 2
      C4/Record.pm
  8. 4
      C4/Search.pm
  9. 2
      C4/Serials.pm
  10. 2
      C4/ShelfBrowser.pm
  11. 6
      Koha/Biblio.pm
  12. 8
      Koha/BiblioUtils.pm
  13. 2
      Koha/Exporter/Record.pm
  14. 5
      Koha/OAI/Server/Repository.pm
  15. 2
      basket/basket.pl
  16. 4
      basket/downloadcart.pl
  17. 4
      basket/sendbasket.pl
  18. 4
      catalogue/ISBDdetail.pl
  19. 4
      catalogue/MARCdetail.pl
  20. 2
      catalogue/detail.pl
  21. 4
      catalogue/export.pl
  22. 2
      catalogue/labeledMARCdetail.pl
  23. 2
      catalogue/moredetail.pl
  24. 2
      catalogue/showmarc.pl
  25. 2
      cataloguing/addbiblio.pl
  26. 8
      cataloguing/additem.pl
  27. 2
      cataloguing/linkitem.pl
  28. 6
      cataloguing/merge.pl
  29. 2
      cataloguing/value_builder/marc21_linking_section.pl
  30. 2
      cataloguing/value_builder/unimarc_field_4XX.pl
  31. 2
      circ/branchoverdues.pl
  32. 2
      circ/reserveratios.pl
  33. 2
      circ/transferstoreceive.pl
  34. 5
      circ/waitingreserves.pl
  35. 2
      misc/batchRebuildBiblioTables.pl
  36. 4
      misc/batchRebuildItemsTables.pl
  37. 2
      misc/batchRepairMissingBiblionumbers.pl
  38. 2
      misc/cronjobs/build_browser_and_cloud.pl
  39. 2
      misc/cronjobs/check-url-quick.pl
  40. 2
      misc/cronjobs/check-url.pl
  41. 2
      misc/link_bibs_to_authorities.pl
  42. 2
      misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl
  43. 2
      misc/maintenance/process_record_through_filter.pl
  44. 2
      misc/maintenance/remove_items_from_biblioitems.pl
  45. 2
      misc/maintenance/sanitize_records.pl
  46. 2
      misc/maintenance/touch_all_biblios.pl
  47. 10
      misc/migration_tools/buildEDITORS.pl
  48. 2
      misc/migration_tools/create_analytical_rel.pl
  49. 2
      misc/migration_tools/import_lexile.pl
  50. 2
      misc/migration_tools/rebuild_zebra.pl
  51. 2
      misc/migration_tools/switch_marc21_series_info.pl
  52. 2
      misc/migration_tools/upgradeitems.pl
  53. 4
      opac/opac-ISBDdetail.pl
  54. 4
      opac/opac-MARCdetail.pl
  55. 2
      opac/opac-basket.pl
  56. 2
      opac/opac-detail.pl
  57. 4
      opac/opac-downloadcart.pl
  58. 4
      opac/opac-downloadshelf.pl
  59. 7
      opac/opac-export.pl
  60. 4
      opac/opac-reserve.pl
  61. 2
      opac/opac-search.pl
  62. 4
      opac/opac-sendbasket.pl
  63. 4
      opac/opac-sendshelf.pl
  64. 2
      opac/opac-shelves.pl
  65. 2
      opac/opac-showmarc.pl
  66. 2
      opac/opac-showreviews.pl
  67. 2
      opac/opac-tags.pl
  68. 2
      opac/opac-user.pl
  69. 4
      serials/subscription-add.pl
  70. 11
      svc/bib
  71. 6
      svc/checkouts
  72. 3
      svc/holds
  73. 7
      svc/new_bib
  74. 2
      svc/records/preview
  75. 6
      t/Biblio.t
  76. 24
      t/db_dependent/Authorities/Merge.t
  77. 8
      t/db_dependent/Biblio.t
  78. 2
      t/db_dependent/Items.t
  79. 4
      t/db_dependent/Koha/Filter/EmbedItemsAvailability.t
  80. 2
      t/db_dependent/OAI/Server.t
  81. 4
      t/db_dependent/OAI/Sets.t
  82. 2
      t/db_dependent/Reserves.t
  83. 2
      tags/list.pl
  84. 2
      tools/batch_delete_records.pl
  85. 2
      tools/batch_record_modification.pl
  86. 4
      tools/showdiffmarc.pl
  87. 4
      virtualshelves/downloadshelf.pl
  88. 4
      virtualshelves/sendshelf.pl
  89. 2
      virtualshelves/shelves.pl

2
C4/AuthoritiesMarc.pm

@ -1475,7 +1475,7 @@ sub merge {
my $counteditedbiblio = 0;
foreach my $biblionumber ( @biblionumbers ) {
my $marcrecord = GetMarcBiblio( $biblionumber );
my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
next if !$marcrecord;
my $update = 0;
foreach my $tagfield (@$tags_using_authtype) {

34
C4/Biblio.pm

@ -293,7 +293,7 @@ sub ModBiblio {
}
if ( C4::Context->preference("CataloguingLog") ) {
my $newrecord = GetMarcBiblio($biblionumber);
my $newrecord = GetMarcBiblio({ biblionumber => $biblionumber });
logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted );
}
@ -1136,11 +1136,18 @@ sub GetMarcSubfieldStructureFromKohaField {
=head2 GetMarcBiblio
my $record = GetMarcBiblio($biblionumber, [$embeditems], [$opac]);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $embeditems,
opac => $opac });
Returns MARC::Record representing a biblio record, or C<undef> if the
biblionumber doesn't exist.
Both embed_items and opac are optional.
If embed_items is passed and is 1, items are embedded.
If opac is passed and is 1, the record is filtered as needed.
=over 4
=item C<$biblionumber>
@ -1161,9 +1168,16 @@ OpacHiddenItems to be applied.
=cut
sub GetMarcBiblio {
my $biblionumber = shift;
my $embeditems = shift || 0;
my $opac = shift || 0;
my ($params) = @_;
if (not defined $params) {
carp 'GetMarcBiblio called without parameters';
return;
}
my $biblionumber = $params->{biblionumber};
my $embeditems = $params->{embed_items} || 0;
my $opac = $params->{opac} || 0;
if (not defined $biblionumber) {
carp 'GetMarcBiblio called with undefined biblionumber';
@ -2181,7 +2195,7 @@ sub PrepHostMarcField {
$marcflavour ||="MARC21";
require C4::Items;
my $hostrecord = GetMarcBiblio($hostbiblionumber);
my $hostrecord = GetMarcBiblio({ biblionumber => $hostbiblionumber });
my $item = C4::Items::GetItem($hostitemnumber);
my $hostmarcfield;
@ -2830,7 +2844,9 @@ sub ModZebra {
);
if ( $op eq 'specialUpdate' ) {
unless ($record) {
$record = GetMarcBiblio($biblionumber, 1);
$record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
}
my $records = [$record];
$indexer->update_index_background( [$biblionumber], [$record] );
@ -3443,7 +3459,7 @@ Generate the host item entry for an analytic child entry
sub prepare_host_field {
my ( $hostbiblio, $marcflavour ) = @_;
$marcflavour ||= C4::Context->preference('marcflavour');
my $host = GetMarcBiblio($hostbiblio);
my $host = GetMarcBiblio({ biblionumber => $hostbiblio });
# unfortunately as_string does not 'do the right thing'
# if field returns undef
my %sfd;
@ -3581,7 +3597,7 @@ sub UpdateTotalIssues {
my ($biblionumber, $increase, $value) = @_;
my $totalissues;
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
unless ($record) {
carp "UpdateTotalIssues could not get biblio record";
return;

2
C4/HoldsQueue.pm

@ -146,7 +146,7 @@ sub GetHoldsQueueItems {
$sth->execute(@bind_params);
my $items = [];
while ( my $row = $sth->fetchrow_hashref ){
my $record = GetMarcBiblio($row->{biblionumber});
my $record = GetMarcBiblio({ biblionumber => $row->{biblionumber} });
if ($record){
$row->{subtitle} = [ map { $_->{subfield} } @{ GetRecordValue( 'subtitle', $record, '' ) } ];
$row->{parts} = GetRecordValue('parts',$record,'')->[0]->{subfield};

4
C4/ILSDI/Services.pm

@ -214,7 +214,9 @@ sub GetRecords {
}
my $embed_items = 1;
my $record = GetMarcBiblio($biblionumber, $embed_items);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $embed_items });
if ($record) {
$biblioitem->{marcxml} = $record->as_xml_record();
}

2
C4/Items.pm

@ -1321,7 +1321,7 @@ references on array of itemnumbers.
sub get_hostitemnumbers_of {
my ($biblionumber) = @_;
my $marcrecord = GetMarcBiblio($biblionumber);
my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
return unless $marcrecord;

4
C4/Labels/Label.pm

@ -396,7 +396,7 @@ sub draw_label_text {
my $font = $self->{'font'};
my $item = _get_label_item($self->{'item_number'});
my $label_fields = _get_text_fields($self->{'format_string'});
my $record = GetMarcBiblio($item->{'biblionumber'});
my $record = GetMarcBiblio({ biblionumber => $item->{'biblionumber'} });
# FIXME - returns all items, so you can't get data from an embedded holdings field.
# TODO - add a GetMarcBiblio1item(bibnum,itemnum) or a GetMarcItem(itemnum).
my $cn_source = ($item->{'cn_source'} ? $item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
@ -601,7 +601,7 @@ sub csv_data {
my $self = shift;
my $label_fields = _get_text_fields($self->{'format_string'});
my $item = _get_label_item($self->{'item_number'});
my $bib_record = GetMarcBiblio($item->{biblionumber});
my $bib_record = GetMarcBiblio({ biblionumber => $item->{biblionumber} });
my @csv_data = (map { _get_barcode_data($_->{'code'},$item,$bib_record) } @$label_fields);
return \@csv_data;
}

2
C4/Record.pm

@ -471,7 +471,7 @@ sub marcrecord2csv {
my $output;
# Getting the record
my $record = GetMarcBiblio($biblio);
my $record = GetMarcBiblio({ biblionumber => $biblio });
return unless $record;
C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblio, $itemnumbers );
# Getting the framework

4
C4/Search.pm

@ -2008,7 +2008,9 @@ sub searchResults {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
if(!$hostbiblionumber eq undef){
my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1);
my $hostbiblio = GetMarcBiblio({
biblionumber => $hostbiblionumber,
embed_items => 1 });
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
if(!$hostbiblio eq undef){
my @hostitems = $hostbiblio->field($itemfield);

2
C4/Serials.pm

@ -1485,7 +1485,7 @@ sub NewSubscription {
#set serial flag on biblio if not already set.
my $biblio = Koha::Biblios->find( $biblionumber );
if ( $biblio and !$biblio->serial ) {
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial', $biblio->frameworkcode );
if ($tag) {
eval { $record->field($tag)->update( $subf => 1 ); };

2
C4/ShelfBrowser.pm

@ -223,7 +223,7 @@ sub GetShelfInfo {
my $this_biblio = GetBibData($item->{biblionumber});
next unless defined $this_biblio;
$item->{'title'} = $this_biblio->{'title'};
my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
my $this_record = GetMarcBiblio({ biblionumber => $this_biblio->{'biblionumber'} });
$item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
$item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
$item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);

6
Koha/Biblio.pm

@ -58,7 +58,11 @@ Keyword to MARC mapping for subtitle must be set for this method to return any p
sub subtitles {
my ( $self ) = @_;
return map { $_->{subfield} } @{ C4::Biblio::GetRecordValue( 'subtitle', C4::Biblio::GetMarcBiblio( $self->id ), $self->frameworkcode ) };
return map { $_->{subfield} } @{
C4::Biblio::GetRecordValue(
'subtitle',
C4::Biblio::GetMarcBiblio({ biblionumber => $self->id }),
$self->frameworkcode ) };
}
=head3 can_article_request

8
Koha/BiblioUtils.pm

@ -121,7 +121,9 @@ sub get_all_biblios_iterator {
while (1) {
my $row = $rs->next();
return if !$row;
my $marc = C4::Biblio::GetMarcBiblio( $row->biblionumber, 1 );
my $marc = C4::Biblio::GetMarcBiblio({
biblionumber => $row->biblionumber,
embed_items => 1 });
my $next = eval {
__PACKAGE__->new($marc, $row->biblionumber);
};
@ -158,7 +160,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( $bibnum, ($options{item_data} ? 1 : 0 ) );
return C4::Biblio::GetMarcBiblio({
biblionumber => $bibnum,
embed_items => ($options{item_data} ? 1 : 0 ) });
}
1;

2
Koha/Exporter/Record.pm

@ -65,7 +65,7 @@ sub _get_biblio_for_export {
my $export_items = $params->{export_items} // 1;
my $only_export_items_for_branch = $params->{only_export_items_for_branch};
my $record = eval { C4::Biblio::GetMarcBiblio($biblionumber); };
my $record = eval { C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); };
return if $@ or not defined $record;

5
Koha/OAI/Server/Repository.pm

@ -160,7 +160,10 @@ sub get_biblio_marcxml {
if ( my $conf = $self->{conf} ) {
$with_items = $conf->{format}->{$format}->{include_items};
}
my $record = GetMarcBiblio($biblionumber, $with_items, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $with_items,
opac => 1 });
$record ? $record->as_xml_record() : undef;
}

2
basket/basket.pl

@ -65,7 +65,7 @@ foreach my $biblionumber ( @bibs ) {
my $dat = &GetBiblioData($biblionumber);
next unless $dat;
my $record = &GetMarcBiblio($biblionumber);
my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
$dat->{subtitle} = GetRecordValue('subtitle', $record, $fw);
my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );

4
basket/downloadcart.pl

@ -65,7 +65,9 @@ if ($bib_list && $format) {
foreach my $biblio (@bibs) {
my $record = GetMarcBiblio($biblio, 1);
my $record = GetMarcBiblio({
biblionumber => $biblio,
embed_items => 1 });
next unless $record;
if ($format eq 'iso2709') {

4
basket/sendbasket.pl

@ -73,7 +73,9 @@ if ( $email_add ) {
my $dat = GetBiblioData($biblionumber);
next unless $dat;
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );

4
catalogue/ISBDdetail.pl

@ -78,7 +78,9 @@ if ( not defined $biblionumber ) {
exit;
}
my $record = GetMarcBiblio($biblionumber,1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
if ( not defined $record ) {
# biblionumber invalid -> report and exit

4
catalogue/MARCdetail.pl

@ -88,7 +88,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
$template->param( ocoins => GetCOinSBiblio($record) );
if ( not defined $record ) {

2
catalogue/detail.pl

@ -63,7 +63,7 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
my $biblionumber = $query->param('biblionumber');
$biblionumber = HTML::Entities::encode($biblionumber);
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if ( not defined $record ) {
# biblionumber invalid -> report and exit

4
catalogue/export.pl

@ -28,7 +28,9 @@ if ($op eq "export") {
my $biblionumber = $query->param("bib");
if ($biblionumber){
my $marc = GetMarcBiblio($biblionumber, 1);
my $marc = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
if ($format =~ /endnote/) {
$marc = marc2endnote($marc);

2
catalogue/labeledMARCdetail.pl

@ -56,7 +56,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if ( not defined $record ) {
# biblionumber invalid -> report and exit
$template->param( unknownbiblionumber => 1,

2
catalogue/moredetail.pl

@ -100,7 +100,7 @@ for my $itm (@all_items) {
($itemnumber != $itm->{itemnumber}));
}
my $record=GetMarcBiblio($biblionumber);
my $record=GetMarcBiblio({ biblionumber => $biblionumber });
my $hostrecords;
# adding items linked via host biblios

2
catalogue/showmarc.pl

@ -46,7 +46,7 @@ if ($importid) {
$record = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
}
else {
$record =GetMarcBiblio($biblionumber);
$record =GetMarcBiblio({ biblionumber => $biblionumber });
}
if(!ref $record) {
print $input->redirect("/cgi-bin/koha/errors/404.pl");

2
cataloguing/addbiblio.pl

@ -770,7 +770,7 @@ my (
);
if (($biblionumber) && !($breedingid)){
$record = GetMarcBiblio($biblionumber);
$record = GetMarcBiblio({ biblionumber => $biblionumber });
}
if ($breedingid) {
( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;

8
cataloguing/additem.pl

@ -411,7 +411,7 @@ $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibra
$restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
my $tagslib = &GetMarcStructure(1,$frameworkcode);
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
my $oldrecord = TransformMarcToKoha($record);
my $itemrecord;
my $nextop="additem";
@ -724,7 +724,7 @@ if ($op eq "additem") {
#-------------------------------------------------------------------------------
# now, build existiing item list
my $temp = GetMarcBiblio( $biblionumber );
my $temp = GetMarcBiblio({ biblionumber => $biblionumber });
#my @fields = $record->fields();
@ -748,7 +748,9 @@ if ( C4::Context->preference('EasyAnalyticalRecords') ) {
foreach my $hostfield ($temp->field($analyticfield)){
my $hostbiblionumber = $hostfield->subfield('0');
if ($hostbiblionumber){
my $hostrecord = GetMarcBiblio($hostbiblionumber, 1);
my $hostrecord = GetMarcBiblio({
biblionumber => $hostbiblionumber,
embed_items => 1 });
if ($hostrecord) {
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
foreach my $hostitem ($hostrecord->field($itemfield)){

2
cataloguing/linkitem.pl

@ -45,7 +45,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
}
);
my $biblio = GetMarcBiblio($biblionumber);
my $biblio = GetMarcBiblio({ biblionumber => $biblionumber });
my $marcflavour = C4::Context->preference("marcflavour");
$marcflavour ||="MARC21";
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC') {

6
cataloguing/merge.pl

@ -78,7 +78,7 @@ if ($merge) {
}
# Rewriting the leader
$record->leader(GetMarcBiblio($ref_biblionumber)->leader());
$record->leader(GetMarcBiblio({ biblionumber => $ref_biblionumber })->leader());
my $frameworkcode = $input->param('frameworkcode');
my @notmoveditems;
@ -115,7 +115,7 @@ if ($merge) {
my $report_header = {};
foreach my $biblionumber ($ref_biblionumber, @biblionumbers) {
# build report
my $marcrecord = GetMarcBiblio($biblionumber);
my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
my %report_record = (
biblionumber => $biblionumber,
fields => {},
@ -202,7 +202,7 @@ if ($merge) {
# Creating a loop for display
my @records;
foreach my $biblionumber (@biblionumbers) {
my $marcrecord = GetMarcBiblio($biblionumber);
my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
my $frameworkcode = GetFrameworkCode($biblionumber);
my $recordObj = new Koha::MetadataRecord({'record' => $marcrecord, schema => $marcflavour});
my $record = {

2
cataloguing/value_builder/marc21_linking_section.pl

@ -85,7 +85,7 @@ my $launcher = sub {
);
#get marc record
$marcrecord = GetMarcBiblio($biblionumber);
$marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
my $subfield_value_9 = $biblionumber;
my $subfield_value_0 = $biblionumber;

2
cataloguing/value_builder/unimarc_field_4XX.pl

@ -96,7 +96,7 @@ sub plugin {
);
#get marc record
$marcrecord = GetMarcBiblio($biblionumber);
$marcrecord = GetMarcBiblio({ biblionumber => $biblionumber });
my $subfield_value_9 = $biblionumber;
my $subfield_value_0;

2
circ/branchoverdues.pl

@ -110,7 +110,7 @@ if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
# now display infos
foreach my $num (@getoverdues) {
my %overdueforbranch;
my $record = GetMarcBiblio($num->{biblionumber});
my $record = GetMarcBiblio({ biblionumber => $num->{biblionumber} });
if ($record){
$overdueforbranch{'subtitle'} = GetRecordValue('subtitle',$record,'')->[0]->{subfield};
}

2
circ/reserveratios.pl

@ -144,7 +144,7 @@ while ( my $data = $sth->fetchrow_hashref ) {
my $thisratio = $data->{reservecount} / $data->{itemcount};
my $ratiocalc = ($thisratio / $ratio);
($thisratio / $ratio) >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause
my $record = GetMarcBiblio($data->{biblionumber});
my $record = GetMarcBiblio({ biblionumber => $data->{biblionumber} });
$data->{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($data->{biblionumber}));
push(
@reservedata,

2
circ/transferstoreceive.pl

@ -109,7 +109,7 @@ while ( my $library = $libraries->next ) {
itemcallnumber => $item->itemcallnumber,
);
my $record = GetMarcBiblio($biblio->biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblio->biblionumber });
$getransf{'subtitle'} = GetRecordValue('subtitle', $record, $biblio->frameworkcode);
# we check if we have a reserv for this transfer

5
circ/waitingreserves.pl

@ -113,7 +113,10 @@ foreach my $num (@getreserves) {
$getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
$getreserv{'title'} = $biblio->title;
$getreserv{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($biblio->biblionumber), $biblio->frameworkcode);
$getreserv{'subtitle'} = GetRecordValue(
'subtitle',
GetMarcBiblio({ biblionumber => $biblio->biblionumber }),
$biblio->frameworkcode);
$getreserv{'biblionumber'} = $biblio->biblionumber;
$getreserv{'barcode'} = $item->barcode;
$getreserv{'homebranch'} = $homebranch;

2
misc/batchRebuildBiblioTables.pl

@ -61,7 +61,7 @@ $sth->execute;
my @errors;
while (my ($biblionumber)= $sth->fetchrow) {
#now, parse the record, extract the item fields, and store them in somewhere else.
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if (not defined $record) {
push @errors, $biblionumber;
next;

4
misc/batchRebuildItemsTables.pl

@ -68,7 +68,9 @@ $sth->execute();
while ( my ( $biblionumber, $biblioitemnumber, $frameworkcode ) = $sth->fetchrow ) {
$count++;
warn $count unless $count % 1000;
my $record = GetMarcBiblio( $biblionumber, 1 );
my $record = GetMarcBiblio({
biblionummber => $biblionumber,
embed_items => 1 });
unless ($record) { push @errors, "bad record biblionumber $biblionumber"; next; }
unless ($test_parameter) {

2
misc/batchRepairMissingBiblionumbers.pl

@ -24,7 +24,7 @@ my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkco
$sth->execute();
while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber, $frameworkcode )};
if($@){

2
misc/cronjobs/build_browser_and_cloud.pl

@ -91,7 +91,7 @@ while ((my ($biblionumber)= $sth->fetchrow)) {
#now, parse the record, extract the item fields, and store them in somewhere else.
my $Koharecord;
eval{
$Koharecord = GetMarcBiblio($biblionumber);
$Koharecord = GetMarcBiblio({ biblionumber => $biblionumber });
};
if($@){
warn 'pb when getting biblio '.$i.' : '.$@;

2
misc/cronjobs/check-url-quick.pl

@ -90,7 +90,7 @@ sub check_all_url {
cb => sub {
return if $count > $maxconn;
while ( my ($biblionumber) = $sth->fetchrow ) {
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
for my $tag (@tags) {
foreach my $field ( $record->field($tag) ) {
my $url = $field->subfield('u');

2
misc/cronjobs/check-url.pl

@ -105,7 +105,7 @@ sub check_biblio {
my $host = $self->{ host_default };
my $bad_url = $self->{ bad_url };
my $record = GetMarcBiblio( $biblionumber );
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
return unless $record->field('856');
my @urls = ();

2
misc/link_bibs_to_authorities.pl

@ -187,7 +187,7 @@ sub process_bib {
my $linker = shift;
my $biblionumber = shift;
my $bib = GetMarcBiblio($biblionumber);
my $bib = GetMarcBiblio({ biblionumber => $biblionumber });
unless ( defined $bib ) {
print
"\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";

2
misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl

@ -87,7 +87,7 @@ my $sth_prepared;
sub updateMarc {
my $id = shift;
my $biblio = GetMarcBiblio($id);
my $biblio = GetMarcBiblio({ biblionumber => $id });
unless ($biblio) {
$debug and warn '[ERROR] GetMarcBiblio did not return any biblio.';

2
misc/maintenance/process_record_through_filter.pl

@ -10,7 +10,7 @@ use Koha::RecordProcessor;
use Data::Dumper;
use C4::Biblio;
my $record = GetMarcBiblio($ARGV[0]);
my $record = GetMarcBiblio({ biblionumber => $ARGV[0] });
print "Before: " . $record->as_formatted() . "\n";
my $processor = Koha::RecordProcessor->new( { filters => ( $ARGV[1] ) });

2
misc/maintenance/remove_items_from_biblioitems.pl

@ -49,7 +49,7 @@ while (my $biblionumber = $query->fetchrow){
$count++;
print "." unless $silent;
print "\r$count" unless ($silent or ($count % 100));
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if ($record) {
ModBiblio($record, $biblionumber, GetFrameworkCode($biblionumber)) ;

2
misc/maintenance/sanitize_records.pl

@ -108,7 +108,7 @@ for my $biblionumber (@biblionumbers) {
say " skipping. ERROR: Invalid biblionumber." if $verbose;
next;
}
my $record = C4::Biblio::GetMarcBiblio($biblionumber);
my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
unless ($record) {
say " skipping. ERROR: Invalid record." if $verbose;
next;

2
misc/maintenance/touch_all_biblios.pl

@ -78,7 +78,7 @@ $sth1->execute();
# fetch info from the search
while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
my $modok = ModBiblio($record, $biblionumber, $frameworkcode);

10
misc/migration_tools/buildEDITORS.pl

@ -70,7 +70,7 @@ my %alreadydone;
my $counter;
my %hash;
while (my ($bibid) = $sth->fetchrow) {
my $record = GetMarcBiblio($bibid);
my $record = GetMarcBiblio({ biblionumber => $bibid });
my $isbnField = $record->field('010');
next unless $isbnField;
my $isbn=$isbnField->subfield('a');
@ -182,8 +182,8 @@ exit;
# # OK, on garde la notice d'autorit� on cherche les notices biblio et on les met �jour...
# if ($fieldnumber eq '710') {
# $sthBIBLIOS710->execute($authentry);
# while (my ($bibid,$tag,$tagorder,$subfieldorder) = $sthBIBLIOS710->fetchrow) {
# my $inbiblio = GetMarcBiblio($bibid);
# while (my ($bibid,$tag,$tagorder,$subfieldorder) = $sthBIBLIOS710->fetchrow) {
# my $inbiblio = GetMarcBiblio({ biblionumber => $bibid });
# my $isOK = 0;
# foreach my $in7xx ($inbiblio->field($fieldnumber)) {
# # !!!!! ici, il faut reconstruire l'entr� de la table de hachage comme ci dessus
@ -203,7 +203,7 @@ exit;
# if ($fieldnumber eq '711') {
# $sthBIBLIOS711->execute($authentry);
# while (my ($bibid,$tag,$tagorder,$subfieldorder) = $sthBIBLIOS711->fetchrow) {
# my $inbiblio = GetMarcBiblio($bibid);
# my $inbiblio = GetMarcBiblio({ biblionumber => $bibid });
# my $isOK = 0;
# foreach my $in7xx ($inbiblio->field($fieldnumber)) {
# # !!!!! ici, il faut reconstruire l'entr� de la table de hachage comme ci dessus
@ -223,7 +223,7 @@ exit;
# if ($fieldnumber eq '712') {
# $sthBIBLIOS712->execute($authentry);
# while (my ($bibid,$tag,$tagorder,$subfieldorder) = $sthBIBLIOS712->fetchrow) {
# my $inbiblio = GetMarcBiblio($bibid);
# my $inbiblio = GetMarcBiblio({ biblionumber => $bibid });
# my $isOK = 0;
# foreach my $in7xx ($inbiblio->field($fieldnumber)) {
# # !!!!! ici, il faut reconstruire l'entr� de la table de hachage comme ci dessus

2
misc/migration_tools/create_analytical_rel.pl

@ -81,7 +81,7 @@ _SUMMARY_
sub process_bib {
my $biblionumber = shift;
my $bib = GetMarcBiblio($biblionumber);
my $bib = GetMarcBiblio({ biblionumber => $biblionumber });
unless (defined $bib) {
print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
$num_bad_bibs++;

2
misc/migration_tools/import_lexile.pl

@ -152,7 +152,7 @@ while ( my $row = $csv->getline_hr($fh) ) {
foreach my $biblionumber (@biblionumbers) {
$counter++;
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if ($verbose) {
say "Found matching record! Biblionumber: $biblionumber";

2
misc/migration_tools/rebuild_zebra.pl

@ -675,7 +675,7 @@ sub get_raw_marc_record {
my $marc;
if ($record_type eq 'biblio') {
eval { $marc = GetMarcBiblio($record_number, 1); };
eval { $marc = GetMarcBiblio({ biblionumber => $record_number, embed_items => 1 }); };
if ($@ || !$marc) {
# here we do warn since catching an exception
# means that the bib was found but failed

2
misc/migration_tools/switch_marc21_series_info.pl

@ -139,7 +139,7 @@ while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) {
my ( @newfields );
# Get biblio marc
my $biblio = GetMarcBiblio( $biblionumber );
my $biblio = GetMarcBiblio({ biblionumber => $biblionumber });
foreach my $field ( $biblio->field( '440' ) ) {
my @newsubfields;

2
misc/migration_tools/upgradeitems.pl

@ -18,7 +18,7 @@ my $rqitemnumber=$dbh->prepare("SELECT itemnumber, biblionumber from items where
$rqbiblios->execute;
$|=1;
while (my ($biblionumber)= $rqbiblios->fetchrow_array){
my $record=GetMarcBiblio($biblionumber);
my $record=GetMarcBiblio({ biblionumber => $biblionumber });
foreach my $itemfield ($record->field('995')){
my $marcitem=MARC::Record->new();
$marcitem->encoding('UTF-8');

4
opac/opac-ISBDdetail.pl

@ -93,7 +93,9 @@ if (scalar @items >= 1) {
}
}
my $record = GetMarcBiblio($biblionumber,1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl");
exit;

4
opac/opac-MARCdetail.pl

@ -71,7 +71,9 @@ if ( ! $biblionumber ) {
exit;
}
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl");
exit;

2
opac/opac-basket.pl

@ -65,7 +65,7 @@ foreach my $biblionumber ( @bibs ) {
my $dat = &GetBiblioData($biblionumber);
next unless $dat;
my $record = &GetMarcBiblio( $biblionumber );
my $record = &GetMarcBiblio({ biblionumber => $biblionumber });
my $framework = &GetFrameworkCode( $biblionumber );
$record_processor->options({
interface => 'opac',

2
opac/opac-detail.pl

@ -90,7 +90,7 @@ if (scalar @all_items >= 1) {
}
}
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
exit;

4
opac/opac-downloadcart.pl

@ -68,7 +68,9 @@ if ($bib_list && $format) {
});
foreach my $biblio (@bibs) {
my $record = GetMarcBiblio($biblio, 1);
my $record = GetMarcBiblio({
biblionumber => $biblio,
embed_items => 1 });
my $framework = &GetFrameworkCode( $biblio );
$record_processor->options({
interface => 'opac',

4
opac/opac-downloadshelf.pl

@ -81,7 +81,9 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) {
while ( my $content = $contents->next ) {
my $biblionumber = $content->biblionumber;
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
my $framework = &GetFrameworkCode( $biblionumber );
$record_processor->options({
interface => 'opac',

7
opac/opac-export.pl

@ -36,8 +36,11 @@ $biblionumber = int($biblionumber);
my $error = q{};
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
my $marc = GetMarcBiblio($biblionumber, $include_items)
if $biblionumber;
my $marc = $biblionumber
? GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $include_items })
: undef;
if(!$marc) {
print $query->redirect("/cgi-bin/koha/errors/404.pl");

4
opac/opac-reserve.pl

@ -159,7 +159,7 @@ foreach my $biblioNumber (@biblionumbers) {
my @itemInfos = GetItemsInfo($biblioNumber);
my $marcrecord= GetMarcBiblio($biblioNumber);
my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber });
# flag indicating existence of at least one item linked via a host record
my $hostitemsflag;
@ -401,7 +401,7 @@ $template->param('item_level_itypes' => $itemLevelTypes);
foreach my $biblioNum (@biblionumbers) {
my @not_available_at = ();
my $record = GetMarcBiblio($biblioNum);
my $record = GetMarcBiblio({ biblionumber => $biblioNum });
# Init the bib item with the choices for branch pickup
my %biblioLoopIter;

2
opac/opac-search.pl

@ -659,7 +659,7 @@ for (my $i=0;$i<@servers;$i++) {
}
if (C4::Context->preference('COinSinOPACResults')) {
my $record = GetMarcBiblio($res->{'biblionumber'});
my $record = GetMarcBiblio({ biblionumber => $res->{'biblionumber'} });
$res->{coins} = GetCOinSBiblio($record);
}
if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) {

4
opac/opac-sendbasket.pl

@ -87,7 +87,9 @@ if ( $email_add ) {
my $dat = GetBiblioData($biblionumber);
next unless $dat;
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );

4
opac/opac-sendshelf.pl

@ -90,7 +90,9 @@ if ( $email ) {
my $biblionumber = $content->biblionumber;
my $fw = GetFrameworkCode($biblionumber);
my $dat = GetBiblioData($biblionumber);
my $record = GetMarcBiblio($biblionumber, 1);
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
my $subtitle = GetRecordValue('subtitle', $record, $fw);

2
opac/opac-shelves.pl

@ -270,7 +270,7 @@ if ( $op eq 'view' ) {
while ( my $content = $contents->next ) {
my $biblionumber = $content->biblionumber;
my $this_item = GetBiblioData($biblionumber);
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
my $framework = GetFrameworkCode( $biblionumber );
$record_processor->options({
interface => 'opac',

2
opac/opac-showmarc.pl

@ -47,7 +47,7 @@ if ($importid) {
$record = MARC::Record->new_from_usmarc($marc);
}
else {
$record = GetMarcBiblio($biblionumber);
$record = GetMarcBiblio({ biblionumber => $biblionumber });
my $framework = GetFrameworkCode($biblionumber);
$record_processor->options({
interface => 'opac',

2
opac/opac-showreviews.pl

@ -91,7 +91,7 @@ for my $result (@$reviews){
my $biblionumber = $result->{biblionumber};
my $biblio = Koha::Biblios->find( $biblionumber );
my $biblioitem = $biblio->biblioitem;
my $record = GetMarcBiblio($biblionumber);
my $record = GetMarcBiblio({ biblionumber => $biblionumber });
my $frameworkcode = GetFrameworkCode($biblionumber);
my $borr = Koha::Patrons->find( $result->{borrowernumber} )->unblessed;
$result->{normalized_upc} = GetNormalizedUPC($record,$marcflavour);

2
opac/opac-tags.pl

@ -232,7 +232,7 @@ if ($loggedinuser) {
my $my_approved_tags = get_approval_rows({ approved => 1 });
foreach my $tag (@$my_tags) {
my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
my $record = &GetMarcBiblio( $tag->{biblionumber} );
my $record = &GetMarcBiblio({ biblionumber => $tag->{biblionumber} });
$tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) );
$tag->{title} = $biblio->title;
$tag->{author} = $biblio->author;

2
opac/opac-user.pl

@ -204,7 +204,7 @@ if ($issues){
}
$issue->{'charges'} = $charges;
$issue->{'rentalfines'} = $rentalfines;
my $marcrecord = GetMarcBiblio( $issue->{'biblionumber'} );
my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} });
$issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'}));
# check if item is renewable
my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );

4
serials/subscription-add.pl

@ -439,7 +439,9 @@ sub redirect_mod_subscription {
sub insert_additional_fields {
my ( $additional_fields, $biblionumber, $subscriptionid ) = @_;
my $record = GetMarcBiblio( $biblionumber, 1 );
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => 1 });
for my $field ( @$additional_fields ) {
my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
if ( $af->{marcfield} ) {

11
svc/bib

@ -66,7 +66,9 @@ exit 0;
sub fetch_bib {
my $query = shift;
my $biblionumber = shift;
my $record = GetMarcBiblio( $biblionumber, $query->url_param('items') );
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $query->url_param('items') });
if (defined $record) {
print $query->header(-type => 'text/xml',-charset => 'utf-8',);
print $record->as_xml_record();
@ -78,7 +80,7 @@ sub fetch_bib {
sub update_bib {
my $query = shift;
my $biblionumber = shift;
my $old_record = GetMarcBiblio($biblionumber);
my $old_record = GetMarcBiblio({ biblionumber => $biblionumber });
unless (defined $old_record) {
print $query->header(-type => 'text/xml', -status => '404 Not Found');
return;
@ -113,8 +115,9 @@ sub update_bib {
}
ModBiblio( $record, $biblionumber, '' );
my $new_record =
GetMarcBiblio( $biblionumber, $query->url_param('items') );
my $new_record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $query->url_param('items') });
$result->{'status'} = "ok";
$result->{'biblionumber'} = $biblionumber;

6
svc/checkouts

@ -209,8 +209,10 @@ while ( my $c = $sth->fetchrow_hashref() ) {
as_due_date => 1
}
),
subtitle =>
GetRecordValue( 'subtitle', GetMarcBiblio( $c->{biblionumber} ), GetFrameworkCode( $c->{biblionumber} ) ),
subtitle => GetRecordValue(
'subtitle',
GetMarcBiblio({ biblionumber => $c->{biblionumber} }),
GetFrameworkCode( $c->{biblionumber} ) ),
lost => $lost,
damaged => $damaged,
borrower => {

3
svc/holds

@ -103,7 +103,8 @@ while ( my $h = $holds_rs->next() ) {
priority => $h->priority(),
itemtype_limit => $itemtype_limit,
subtitle => GetRecordValue(
'subtitle', GetMarcBiblio($biblionumber),
'subtitle',
GetMarcBiblio({ biblionumber => $biblionumber }),
GetFrameworkCode($biblionumber)
),
reservedate_formatted => $h->reservedate() ? output_pref(

7
svc/new_bib

@ -75,7 +75,7 @@ sub add_bib {
$record->delete_field($field);
}
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
my $new_record = GetMarcBiblio($biblionumber);
my $new_record = GetMarcBiblio({ biblionumber => $biblionumber });
if ( $query->url_param('items') ) {
foreach my $field ( $fullrecord->field($itemtag) ) {
my $one_item_record = $new_record->clone();
@ -84,8 +84,9 @@ sub add_bib {
}
}
$new_record =
GetMarcBiblio( $biblionumber, $query->url_param('items') );
$new_record = GetMarcBiblio({
biblionumber => $biblionumber,
embed_items => $query->url_param('items') });
$result->{'status'} = "ok";
$result->{'biblionumber'} = $biblionumber;
my $xml = $new_record->as_xml_record();

2
svc/records/preview

@ -32,7 +32,7 @@ my $mmtid = $query->param('mmtid'); # Marc modification template id
my $record;
if ( $record_type eq 'biblio' ) {
$record = GetMarcBiblio( $record_id );
$record = GetMarcBiblio({ biblionumber => $record_id });
} else {
my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
$record = $authority->record;

6
t/Biblio.t

@ -25,7 +25,7 @@ use Module::Load::Conditional qw/check_install/;
BEGIN {
if ( check_install( module => 'Test::DBIx::Class' ) ) {
plan tests => 46;
plan tests => 47;
} else {
plan skip_all => "Need Test::DBIx::Class"
}
@ -181,6 +181,10 @@ warning_is { $ret = RemoveAllNsb() }
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
warning_is { $ret = GetMarcBiblio() }
{ carped => 'GetMarcBiblio called without parameters'},
"GetMarcBiblio returns carped warning on no parameters";
warning_is { $ret = GetMarcBiblio({ biblionumber => undef }) }