Browse Source

Bug 26781: Check for subfield defined rather than truth

To recreate:
 1 - Have a record with 100$0 defined
 2 - Define a Marc Modification template:
    Delete field 100$0
 3 - Perform Batch record modification, enter the record above in the list of records
 4 - Preview the MARC
 5 - Note the entire 100 field has been deleted, don't modify the record
 6 - Apply patch
 7 - Restart all the things
 8 - Test the modification again
 9 - This time the preview confirms only the subfield 0 deleted
10 - Modify the record
11 - Confirm the record is correctly updated

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

JD amended patch: Fix typo ony vs only

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Nick Clemens 10 months ago
committed by Jonathan Druart
parent
commit
be4f0c7639
  1. 2
      Koha/SimpleMARC.pm
  2. 14
      t/SimpleMARC.t

2
Koha/SimpleMARC.pm

@ -526,7 +526,7 @@ sub delete_field {
my $subfieldName = $params->{subfield};
my $field_numbers = $params->{field_numbers} // [];
if ( not $subfieldName or $subfieldName eq '' ) {
if ( !defined $subfieldName or $subfieldName eq '' ) {
_delete_field({ record => $record, field => $fieldName, field_numbers => $field_numbers });
} else {
_delete_subfield({ record => $record, field => $fieldName, subfield => $subfieldName, field_numbers => $field_numbers });

14
t/SimpleMARC.t

@ -1676,7 +1676,7 @@ subtest 'move_field' => sub {
subtest 'delete_field' => sub {
plan tests => 2;
subtest 'delete subfield' => sub {
plan tests => 2;
plan tests => 3;
my $record = new_record;
$record->append_fields(
MARC::Field->new(
@ -1710,6 +1710,18 @@ subtest 'delete_field' => sub {
@fields_952p =
read_field( { record => $record, field => '952', subfield => 'p' } );
is_deeply( \@fields_952p, [], 'Delete all 952$p' );
$record = new_record;
$record->append_fields(
MARC::Field->new(
600, ' ', ' ',
a => 'Murakami, Haruki',
0 => 'https://id.loc.gov/authorities/names/n81152393.html',
),
);
delete_field( { record => $record, field => '600', subfield => '0' } );
my @fields_600 = read_field( { record => $record, field => '600' } );
is_deeply( \@fields_600, ['Murakami, Haruki'], 'Delete all 600$0, only subfield 0 deleted' );
};
subtest 'delete field' => sub {

Loading…
Cancel
Save