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> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
01b578de15
commit
2c52b27d8c
23 changed files with 47 additions and 46 deletions
|
@ -218,7 +218,7 @@ sub GetRecords {
|
|||
|
||||
my $biblioitem = $biblio->biblioitem->unblessed;
|
||||
|
||||
my $record = $biblio->metadata->record({ embed_items => 1, opac => 1, });
|
||||
my $record = $biblio->metadata_record( { embed_items => 1 } );
|
||||
if ($record) {
|
||||
$biblioitem->{marcxml} = $record->as_xml_record( C4::Context->preference('marcflavour') );
|
||||
}
|
||||
|
|
|
@ -151,7 +151,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 ($@) {
|
||||
|
@ -187,8 +187,7 @@ 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) = @_;
|
||||
|
||||
my $record = Koha::Biblios->find($bibnum)
|
||||
->metadata->record( { $options{item_data} ? ( embed_items => 1 ) : () } );
|
||||
my $record = Koha::Biblios->find($bibnum)->metadata_record( { $options{item_data} ? ( embed_items => 1 ) : () } );
|
||||
return $record;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = $@;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -60,7 +60,7 @@ if ( $op eq "cud-send" && $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 ) {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -90,10 +90,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|||
);
|
||||
|
||||
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
|
||||
my $record;
|
||||
$record = $biblio_object->metadata->record({ embed_items => 1 }) if $biblio_object;
|
||||
my $record = $biblio_object ? $biblio_object->metadata_record( { embed_items => 1 } ) : undef;
|
||||
|
||||
if ( not defined $record ) {
|
||||
if ( !$record ) {
|
||||
# biblionumber invalid -> report and exit
|
||||
$template->param( unknownbiblionumber => 1,
|
||||
biblionumber => $biblionumber
|
||||
|
|
|
@ -27,7 +27,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 } );
|
||||
|
||||
my $metadata_extractor = $biblio->metadata_extractor;
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -697,7 +697,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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
);
|
||||
|
|
|
@ -70,10 +70,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,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -54,7 +54,7 @@ if ( $op eq "cud-send" && $email_add && $user_email ) {
|
|||
foreach my $bib (@bibs) {
|
||||
$bib = int($bib);
|
||||
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 ) {
|
||||
|
|
|
@ -71,7 +71,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 ) {
|
||||
|
|
|
@ -254,10 +254,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,
|
||||
}
|
||||
);
|
||||
|
|
|
@ -293,7 +293,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') );
|
||||
}
|
||||
|
|
9
svc/bib
9
svc/bib
|
@ -64,14 +64,13 @@ if ($query->request_method eq "GET") {
|
|||
exit 0;
|
||||
|
||||
sub fetch_bib {
|
||||
my $query = shift;
|
||||
my $biblionumber = shift;
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
my ( $query, $biblionumber ) = @_;
|
||||
my $biblio = Koha::Biblios->find($biblionumber);
|
||||
my $record;
|
||||
my $exception;
|
||||
my $invalid_metadata = 0;
|
||||
if ( defined $biblio ) {
|
||||
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 +125,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;
|
||||
|
|
|
@ -87,8 +87,8 @@ sub add_bib {
|
|||
}
|
||||
}
|
||||
|
||||
$biblio = Koha::Biblios->find( $biblionumber );
|
||||
$new_record = $biblio->metadata->record({ embed_items => scalar $query->url_param('items') });
|
||||
$biblio = Koha::Biblios->find($biblionumber);
|
||||
$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();
|
||||
|
|
|
@ -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' ) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ if ( $to_address && $op eq 'cud-send' ) {
|
|||
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 ) {
|
||||
|
|
Loading…
Reference in a new issue