Bugzilla – Attachment 112488 Details for
Bug 26781
Marc Modification Templates treat subfield 0 and no subfield set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26781: Check for subfield defined rather than truth
Bug-26781-Check-for-subfield-defined-rather-than-t.patch (text/plain), 2.84 KB, created by
Jonathan Druart
on 2020-10-25 21:57:53 UTC
(
hide
)
Description:
Bug 26781: Check for subfield defined rather than truth
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-10-25 21:57:53 UTC
Size:
2.84 KB
patch
obsolete
>From e6415b65124e4b2a854d762d6f250261c1509635 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 22 Oct 2020 10:59:17 +0000 >Subject: [PATCH] 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 >--- > Koha/SimpleMARC.pm | 2 +- > t/SimpleMARC.t | 14 +++++++++++++- > 2 files changed, 14 insertions(+), 2 deletions(-) > >diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm >index 82c3adc6f7..2867dc1cd6 100644 >--- a/Koha/SimpleMARC.pm >+++ b/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 }); >diff --git a/t/SimpleMARC.t b/t/SimpleMARC.t >index 4fd8933b29..6455820fbb 100755 >--- a/t/SimpleMARC.t >+++ b/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 { >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26781
:
112164
|
112409
|
112433
|
112434
| 112488 |
112826