Bug 39545: (QA follow-up) Restore 240 field processing for subfield s

This patch restores the generation of subfield s from field 240 (Uniform Title)
in the MARC21 773 field generation, addressing cataloger feedback about the
critical importance of this field for:

- Bibles and books of the Bible
- Laws and statutes
- Translations
- Academic and specialized library materials
- Legal materials and treaties

The MARC21 standard defines subfield s as "Uniform title (NR)" and this data
is essential for proper bibliographic relationships.

This patch also fixes a warning when 245 indicator 2 contains non-numeric
values by adding proper validation.

Test plan:
1. Create a record with a 240 field containing uniform title data
2. Generate a child record from it
3. Verify the 773 field now contains subfield s with the uniform title
4. Run prove t/db_dependent/Koha/Biblio.t to ensure all tests pass

Sponsored-by: Open Fifth <https://openfifth.co.uk>
Signed-off-by: Heather Hernandez <flyingendpaper@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5f025aee75)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Martin Renvoize 2025-06-26 16:08:28 +01:00 committed by Paul Derscheid
parent a7116a88cf
commit 17e8a890f4
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 18 additions and 2 deletions

View File

@ -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');

View File

@ -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' ),