Bug 35423: Fix substr outside of string warning

To test:

Before applying patch

1. Create an authority record, fill field 400$w with "n"
2. Search for the authority you just created
3. Observe a warning has been logged

"substr outside of string"

4. Apply patch
5. Refresh the search results from step 2
6. Observe no warnings have been logged

Signed-off-by: Harrison Hawkins <harrisonhawkins@catalyst.net.nz>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lari Taskula 2025-10-21 22:34:18 +03:00 committed by Lucas Gass
parent 1e84cbd496
commit 3c34d7bf43
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 2 additions and 2 deletions

View File

@ -1080,7 +1080,7 @@ sub BuildSummary {
my $type = 'seefrom';
$type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
if ( $type eq 'notapplicable' ) {
$type = substr $field->subfield('w'), 2, 1;
$type = substr $field->subfield('w'), 2, 1 if length( $field->subfield('w') ) > 2;
$type = 'earlier' if $type && $type ne 'n';
}
if ( $type eq 'subfi' ) {
@ -1103,7 +1103,7 @@ sub BuildSummary {
my $type = 'seealso';
$type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
if ( $type eq 'notapplicable' ) {
$type = substr $field->subfield('w'), 2, 1;
$type = substr $field->subfield('w'), 2, 1 if length( $field->subfield('w') ) > 2;
$type = 'earlier' if $type && $type ne 'n';
}
if ( $type eq 'subfi' ) {