Bugzilla – Attachment 161938 Details for
Bug 31224
Koha::Biblio::Metadata->record should use the EmbedItems filter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31224: Update instances of metadata->record
Bug-31224-Update-instances-of-metadata-record.patch (text/plain), 16.55 KB, created by
Martin Renvoize (ashimema)
on 2024-02-08 16:53:43 UTC
(
hide
)
Description:
Bug 31224: Update instances of metadata->record
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-02-08 16:53:43 UTC
Size:
16.55 KB
patch
obsolete
>From a0e0c00f09e5c5f89d13709783c9b9a2543bdac3 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 18 Oct 2022 16:46:08 +0100 >Subject: [PATCH] Bug 31224: Update instances of metadata->record > >We can now call metadata_record directly on the Koha::Biblio object. > >This aptch updates all modules and controllers to use >Koha::Biblio->metadata_record directly where appropriate. The >exceptions are where we don't require any filtering or the filtering >makes sense to do after the initial fetch. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/ILSDI/Services.pm | 2 +- > Koha/BiblioUtils.pm | 4 ++-- > Koha/OAI/Server/Repository.pm | 9 ++++++++- > Koha/SearchEngine/Elasticsearch/Indexer.pm | 2 +- > basket/downloadcart.pl | 2 +- > basket/sendbasket.pl | 2 +- > catalogue/ISBDdetail.pl | 13 ++----------- > catalogue/MARCdetail.pl | 2 +- > catalogue/export.pl | 2 +- > misc/batchRebuildItemsTables.pl | 2 +- > misc/migration_tools/rebuild_zebra.pl | 2 +- > opac/opac-downloadcart.pl | 4 ++-- > opac/opac-downloadshelf.pl | 4 ++-- > opac/opac-export.pl | 4 ++-- > opac/opac-sendbasket.pl | 2 +- > opac/opac-sendshelf.pl | 2 +- > opac/opac-tags.pl | 4 ++-- > opac/opac-user.pl | 8 +++++++- > svc/bib | 4 ++-- > svc/new_bib | 2 +- > tools/showdiffmarc.pl | 2 +- > virtualshelves/downloadshelf.pl | 2 +- > virtualshelves/sendshelf.pl | 2 +- > 23 files changed, 43 insertions(+), 39 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 07cea34da30..ae0a4b55ab2 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -218,7 +218,7 @@ sub GetRecords { > > my $biblioitem = $biblio->biblioitem->unblessed; > >- my $record = $biblio->metadata->record({ embed_items => 1 }); >+ my $record = $biblio->metadata_record({ embed_items => 1 }); > if ($record) { > $biblioitem->{marcxml} = $record->as_xml_record(); > } >diff --git a/Koha/BiblioUtils.pm b/Koha/BiblioUtils.pm >index cb7baed0dbd..4d708ab813f 100644 >--- a/Koha/BiblioUtils.pm >+++ b/Koha/BiblioUtils.pm >@@ -146,7 +146,7 @@ sub get_all_biblios_iterator { > my $row = $rs->next(); > return if !$row; > my $next = eval { >- my $marc = $row->metadata->record({ embed_items => 1 }); >+ my $marc = $row->metadata_record({ embed_items => 1 }); > $class->new($marc, $row->biblionumber); > }; > if ($@) { >@@ -183,7 +183,7 @@ sub get_marc_biblio { > my ($class, $bibnum, %options) = @_; > > my $record = Koha::Biblios->find($bibnum) >- ->metadata->record( { $options{item_data} ? ( embed_items => 1 ) : () } ); >+ ->metadata_record( { $options{item_data} ? ( embed_items => 1 ) : () } ); > return $record; > } > >diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm >index 4ec02811abc..d0e5c466676 100644 >--- a/Koha/OAI/Server/Repository.pm >+++ b/Koha/OAI/Server/Repository.pm >@@ -185,7 +185,14 @@ sub get_biblio_marcxml { > > # Koha::Biblio::Metadata->record throws an exception on bad encoding, > # we don't want OAI harvests to die, so we catch and warn, and try to clean the record >- eval { $record = $biblio->metadata->record( { embed_items => $with_items, opac => 1 } ); }; >+ eval { >+ $record = $biblio->metadata_record( >+ { >+ embed_items => $with_items, >+ interface => 'opac' >+ } >+ ); >+ }; > my $decoding_error; > if ($@) { > my $exception = $@; >diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm >index 1f914b8a651..8a8c73f7952 100644 >--- a/Koha/SearchEngine/Elasticsearch/Indexer.pm >+++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm >@@ -349,7 +349,7 @@ sub _get_record { > > if ( $self->index eq $Koha::SearchEngine::BIBLIOS_INDEX ) { > my $biblio = Koha::Biblios->find($record_id); >- $record = $biblio->metadata->record( { embed_items => 1 } ) >+ $record = $biblio->metadata_record( { embed_items => 1 } ) > if $biblio; > } else { > $record = C4::AuthoritiesMarc::GetAuthority($record_id); >diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl >index 806ad4959fe..6013c75b19e 100755 >--- a/basket/downloadcart.pl >+++ b/basket/downloadcart.pl >@@ -64,7 +64,7 @@ if ($bib_list && $format) { > foreach my $biblionumber (@bibs) { > > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record({ embed_items => 1 }); >+ my $record = $biblio->metadata_record({ embed_items => 1 }); > next unless $record; > > if ($format eq 'iso2709') { >diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl >index e863497d32b..8567cd43d71 100755 >--- a/basket/sendbasket.pl >+++ b/basket/sendbasket.pl >@@ -67,7 +67,7 @@ if ($email_add) { > > foreach my $bib (@bibs) { > my $biblio = Koha::Biblios->find($bib) or next; >- $iso2709 .= $biblio->metadata->record->as_usmarc(); >+ $iso2709 .= $biblio->metadata_record()->as_usmarc(); > } > > if ( !defined $iso2709 ) { >diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl >index d7431e8bc8d..90bbb51f842 100755 >--- a/catalogue/ISBDdetail.pl >+++ b/catalogue/ISBDdetail.pl >@@ -76,8 +76,8 @@ unless ( $biblionumber && $biblio ) { > exit; > } > >-my $record = $biblio->metadata->record({ embed_items => 1 }); >- >+my $record = >+ $biblio->metadata_record( { embed_items => 1, interface => 'intranet' } ); > if ( not defined $record ) { > # biblionumber invalid -> report and exit > $template->param( unknownbiblionumber => 1, >@@ -88,15 +88,6 @@ if ( not defined $record ) { > } > > my $framework = $biblio->frameworkcode; >-my $record_processor = Koha::RecordProcessor->new({ >- filters => 'ViewPolicy', >- options => { >- interface => 'intranet', >- frameworkcode => $framework >- }, >-}); >-$record_processor->process($record); >- > my $res = GetISBDView({ > 'record' => $record, > 'template' => 'intranet', >diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl >index 3f5e03a0904..80704812ca0 100755 >--- a/catalogue/MARCdetail.pl >+++ b/catalogue/MARCdetail.pl >@@ -90,7 +90,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > ); > > my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio >-my $record = $biblio_object->metadata->record({ embed_items => 1 }); >+my $record = $biblio_object->metadata_record({ embed_items => 1 }); > > if ( not defined $record ) { > # biblionumber invalid -> report and exit >diff --git a/catalogue/export.pl b/catalogue/export.pl >index ff02cea67f0..4e6d5517665 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -28,7 +28,7 @@ if ($op eq "export") { > my $file_pre = "bib-"; > > my $biblio = Koha::Biblios->find($biblionumber); >- my $marc = $biblio->metadata->record({ embed_items => 1 }); >+ my $marc = $biblio->metadata_record({ embed_items => 1 }); > > if( C4::Context->preference('DefaultSaveRecordFileID') eq 'controlnumber' ){ > my $marcflavour = C4::Context->preference('marcflavour'); #FIXME This option is required but does not change control num behaviour >diff --git a/misc/batchRebuildItemsTables.pl b/misc/batchRebuildItemsTables.pl >index 220876a8b8f..b16cb0476fd 100755 >--- a/misc/batchRebuildItemsTables.pl >+++ b/misc/batchRebuildItemsTables.pl >@@ -74,7 +74,7 @@ while ( my ( $biblionumber, $biblioitemnumber, $frameworkcode ) = $sth->fetchrow > $count++; > warn $count unless $count % 1000; > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record({ embed_items => 1 }); >+ my $record = $biblio->metadata_record({ embed_items => 1 }); > > unless ($record) { push @errors, "bad record biblionumber $biblionumber"; next; } > >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index ec19ce1f5c4..d7d17a36489 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -682,7 +682,7 @@ sub get_raw_marc_record { > if ($record_type eq 'biblio') { > eval { > my $biblio = Koha::Biblios->find($record_number); >- $marc = $biblio->metadata->record({ embed_items => 1 }); >+ $marc = $biblio->metadata_record({ embed_items => 1 }); > }; > if ($@ || !$marc) { > # here we do warn since catching an exception >diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl >index 1f4b20d1fb4..db103bacba9 100755 >--- a/opac/opac-downloadcart.pl >+++ b/opac/opac-downloadcart.pl >@@ -77,10 +77,10 @@ if ($bib_list && $format) { > foreach my $biblionumber (@bibs) { > > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record( >+ my $record = $biblio->metadata_record( > { > embed_items => 1, >- opac => 1, >+ interface => 'opac', > patron => $patron, > } > ); >diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl >index ea81c1e7cea..0d6f9e88a01 100755 >--- a/opac/opac-downloadshelf.pl >+++ b/opac/opac-downloadshelf.pl >@@ -90,10 +90,10 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { > my $biblionumber = $content->biblionumber; > > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record( >+ my $record = $biblio->metadata_record( > { > embed_items => 1, >- opac => 1, >+ interface => 'opac', > patron => $patron, > } > ); >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index 1b0fdad59ac..0679f48bdc4 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -54,10 +54,10 @@ if ($userenv) { > my $include_items = ($format =~ /bibtex/) ? 0 : 1; > my $biblio = Koha::Biblios->find($biblionumber); > my $marc = $biblio >- ? $biblio->metadata->record( >+ ? $biblio->metadata_record( > { > embed_items => 1, >- opac => 1, >+ interface => 'opac', > patron => $patron, > } > ) >diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl >index d0ff9fc53a6..3c8cc3d3d74 100755 >--- a/opac/opac-sendbasket.pl >+++ b/opac/opac-sendbasket.pl >@@ -66,7 +66,7 @@ if ( $email_add ) { > my $iso2709; > foreach my $bib (@bibs) { > my $biblio = Koha::Biblios->find($bib) or next; >- $iso2709 .= $biblio->metadata->record->as_usmarc(); >+ $iso2709 .= $biblio->metadata_record({ interface => 'opac' })->as_usmarc(); > } > > if ( !defined $iso2709 ) { >diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl >index e08b474cb15..2f6116844ea 100755 >--- a/opac/opac-sendshelf.pl >+++ b/opac/opac-sendshelf.pl >@@ -70,7 +70,7 @@ if ( $shelf and $shelf->can_be_viewed($borrowernumber) ) { > while ( my $content = $contents->next ) { > push @biblionumbers, $content->biblionumber; > my $biblio = Koha::Biblios->find( $content->biblionumber ); >- $iso2709 .= $biblio->metadata->record->as_usmarc(); >+ $iso2709 .= $biblio->metadata_record({ interface => 'opac' })->as_usmarc(); > } > > if ( !defined $iso2709 ) { >diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl >index 43f156d31b4..efb1735aef2 100755 >--- a/opac/opac-tags.pl >+++ b/opac/opac-tags.pl >@@ -250,10 +250,10 @@ if ($loggedinuser) { > foreach my $tag (@$my_tags) { > $tag->{visible} = 0; > my $biblio = Koha::Biblios->find( $tag->{biblionumber} ); >- my $record = $biblio->metadata->record( >+ my $record = $biblio->metadata_record( > { > embed_items => 1, >- opac => 1, >+ interface => 'opac', > patron => $patron, > } > ); >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 5c7296b201d..342cf3bacd0 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -301,7 +301,13 @@ if ( $pending_checkouts->count ) { # Useless test > || C4::Context->preference('SyndeticsEnabled') > || C4::Context->preference('SyndeticsCoverImages') ) > { >- my $marcrecord = $biblio_object->metadata->record( { embed_items => 1, opac => 1, patron => $patron, } ); >+ my $marcrecord = $biblio_object->metadata_record( >+ { >+ embed_items => 1, >+ interface => 'opac', >+ patron => $patron >+ } >+ ); > $issue->{normalized_upc} = GetNormalizedUPC( $marcrecord, C4::Context->preference('marcflavour') ); > $issue->{normalized_oclc} = GetNormalizedOCLCNumber( $marcrecord, C4::Context->preference('marcflavour') ); > } >diff --git a/svc/bib b/svc/bib >index 53e6fc753ed..5614c4156e0 100755 >--- a/svc/bib >+++ b/svc/bib >@@ -70,7 +70,7 @@ sub fetch_bib { > my $record; > my $exception; > my $invalid_metadata = 0; >- eval { $record = $biblio->metadata->record( { embed_items => scalar $query->param('items') } ) }; >+ eval { $record = $biblio->metadata_record( { embed_items => scalar $query->param('items') } ) }; > if ($@) { > $exception = $@; > $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') ); >@@ -126,7 +126,7 @@ sub update_bib { > > C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode ); > my $biblio = Koha::Biblios->find( $biblionumber ); >- my $new_record = $biblio->metadata->record({ embed_items => scalar $query->url_param('items') }); >+ my $new_record = $biblio->metadata_record({ embed_items => scalar $query->url_param('items') }); > > $result->{'status'} = "ok"; > $result->{'biblionumber'} = $biblionumber; >diff --git a/svc/new_bib b/svc/new_bib >index 3ce32f6b7c8..300e1133b3e 100755 >--- a/svc/new_bib >+++ b/svc/new_bib >@@ -88,7 +88,7 @@ sub add_bib { > } > > $biblio = Koha::Biblios->find( $biblionumber ); >- $new_record = $biblio->metadata->record({ embed_items => scalar $query->url_param('items') }); >+ $new_record = $biblio->metadata_record({ embed_items => scalar $query->url_param('items') }); > $result->{'status'} = "ok"; > $result->{'biblionumber'} = $biblionumber; > my $xml = $new_record->as_xml_record(); >diff --git a/tools/showdiffmarc.pl b/tools/showdiffmarc.pl >index f981342a83c..ddd9deb9d0d 100755 >--- a/tools/showdiffmarc.pl >+++ b/tools/showdiffmarc.pl >@@ -62,7 +62,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > if ( $type eq 'biblio' ) { > my $biblio = Koha::Biblios->find( $recordid ); >- $record = $biblio->metadata->record({ embed_items => 1 }); >+ $record = $biblio->metadata_record({ embed_items => 1 }); > $recordTitle = $biblio->title; > } > elsif ( $type eq 'auth' ) { >diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl >index 1138b530ce3..9e73921c3bc 100755 >--- a/virtualshelves/downloadshelf.pl >+++ b/virtualshelves/downloadshelf.pl >@@ -69,7 +69,7 @@ if ($shelfid && $format) { > while ( my $content = $contents->next ) { > my $biblionumber = $content->biblionumber; > my $biblio = Koha::Biblios->find($biblionumber); >- my $record = $biblio->metadata->record({ embed_items => 1 }); >+ my $record = $biblio->metadata_record({ embed_items => 1 }); > if ($format eq 'iso2709') { > $output .= $record->as_usmarc(); > } >diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl >index e50f3c3cd35..33e9ad73036 100755 >--- a/virtualshelves/sendshelf.pl >+++ b/virtualshelves/sendshelf.pl >@@ -69,7 +69,7 @@ if ($to_address) { > while ( my $content = $contents->next ) { > push @biblionumbers, $content->biblionumber; > my $biblio = Koha::Biblios->find( $content->biblionumber ); >- $iso2709 .= $biblio->metadata->record->as_usmarc(); >+ $iso2709 .= $biblio->metadata_record()->as_usmarc(); > } > > if ( !defined $iso2709 ) { >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31224
:
138060
|
138061
|
138062
|
138063
|
138064
|
142137
|
142138
|
142139
|
142140
|
142141
|
142142
|
142143
|
161933
|
161934
|
161935
|
161936
|
161937
|
161938
|
161939
|
161940
|
161941
|
161942
|
161943
|
161944
|
173530
|
173531
|
173532
|
173533
|
173534
|
173535
|
173588
|
173597
|
173598
|
173636
|
173637
|
173638
|
173639
|
173640
|
173641
|
173642
|
173643
|
173644
|
174262
|
174263