diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index acaadc6189..4c88bcd8a5 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1972,7 +1972,8 @@ sub generate_marc_host_field { my $t = $f245c->as_string; $t =~ s/[\s\/\\.]+$//; my $nonfiling = $f245c->indicator('2') // 0; - $t = ucfirst substr( $t, $nonfiling ); + $nonfiling = 0 unless $nonfiling =~ /^\d+$/; + $t = ucfirst substr( $t, $nonfiling ); push @sfd, ( 't' => $t ); } @@ -1985,6 +1986,14 @@ sub generate_marc_host_field { } } + # Subfield s - uniform title from 240 + if ( my $f240 = $marc_host->field('240') ) { + my $s = $f240->as_string('a'); + if ($s) { + push @sfd, ( 's' => $s ); + } + } + # Subfield d - publication info from 264/260 my $d; my @publication_fields = $marc_host->field('264'); diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 731278cc36..f0d32ee300 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -1016,7 +1016,7 @@ subtest 'get_volumes_query' => sub { }; subtest 'generate_marc_host_field' => sub { - plan tests => 35; + plan tests => 36; $schema->storage->txn_begin; @@ -1101,6 +1101,13 @@ subtest 'generate_marc_host_field' => sub { $link = $biblio->generate_marc_host_field(); is( $link->subfield('t'), 'The capital test', "Title is capitalized after indicator offset" ); + # 240 uniform title tests + $record->append_fields( MARC::Field->new( '240', '1', '0', 'a' => 'Bible. English', 'l' => 'English' ) ); + ($biblio_id) = AddBiblio( $record, qw{} ); + $biblio = Koha::Biblios->find($biblio_id); + $link = $biblio->generate_marc_host_field(); + is( $link->subfield('s'), 'Bible. English', "Subfield s contains uniform title from 240a" ); + # 260/264 handling tests $record->append_fields( MARC::Field->new( '264', '', '', a => 'Publication 264' ),