Bugzilla – Attachment 180686 Details for
Bug 39504
Batch record modification 'doesn't exist' condition not checking every matching tag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39504: [WIP] Make MARC modification templates return not_exists fields for actions
Bug-39504-WIP-Make-MARC-modification-templates-ret.patch (text/plain), 2.88 KB, created by
Aleisha Amohia
on 2025-04-06 23:11:10 UTC
(
hide
)
Description:
Bug 39504: [WIP] Make MARC modification templates return not_exists fields for actions
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2025-04-06 23:11:10 UTC
Size:
2.88 KB
patch
obsolete
>From 6df59b96f40baa7b8a2e80c8858766e3535b3c2b Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Sun, 6 Apr 2025 23:10:01 +0000 >Subject: [PATCH] Bug 39504: [WIP] Make MARC modification templates return > not_exists fields for actions >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Tests coming > >Sponsored-by: MÄoriland Film Festival >--- > C4/MarcModificationTemplates.pm | 8 +++++--- > Koha/SimpleMARC.pm | 12 +++++++++--- > 2 files changed, 14 insertions(+), 6 deletions(-) > >diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm >index 9fa267362e3..27b2dc38e06 100644 >--- a/C4/MarcModificationTemplates.pm >+++ b/C4/MarcModificationTemplates.pm >@@ -548,7 +548,8 @@ sub ModifyRecordWithTemplate { > ? @$field_numbers > : not @$field_numbers; > } elsif ( $conditional_comparison eq 'not_exists' ) { >- $field_numbers = field_exists( >+ my $not_exists_numbers = []; >+ ( $field_numbers, $not_exists_numbers ) = field_exists( > { > record => $record, > field => $conditional_field, >@@ -556,9 +557,10 @@ sub ModifyRecordWithTemplate { > } > ); > $do = >- $conditional eq 'if' >- ? not @$field_numbers >+ $conditional eq 'if' >+ ? @$not_exists_numbers > : @$field_numbers; >+ $field_numbers = $not_exists_numbers; > } elsif ( $conditional_comparison eq 'equals' ) { > $field_numbers = field_equals( > { >diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm >index 65d1cec0c29..76ab89cd304 100644 >--- a/Koha/SimpleMARC.pm >+++ b/Koha/SimpleMARC.pm >@@ -385,6 +385,8 @@ sub _read_subfield { > > Returns the field numbers or an empty array. > >+ Also returns the not_exists field numbers if looking at subfieldName too. >+ > =cut > > sub field_exists { >@@ -396,18 +398,22 @@ sub field_exists { > if ( !$record ) { return; } > > my @field_numbers = (); >+ my @not_exists_numbers = (); > my $current_field_number = 1; > for my $field ( $record->field($fieldName) ) { > if ($subfieldName) { >- push @field_numbers, $current_field_number >- if $field->subfield($subfieldName); >+ if ( $field->subfield($subfieldName) ) { >+ push @field_numbers, $current_field_number; >+ } else { >+ push @not_exists_numbers, $current_field_number; >+ } > } else { > push @field_numbers, $current_field_number; > } > $current_field_number++; > } > >- return \@field_numbers; >+ return ( \@field_numbers, \@not_exists_numbers ); > } > > =head2 field_equals >-- >2.39.5
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 39504
: 180686