Bugzilla – Attachment 69804 Details for
Bug 19813
MarcItemFieldsToOrder cannot handle a tag not existing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19813 - MarcItemFieldsToOrder cannot handle a tag not existing
Bug-19813---MarcItemFieldsToOrder-cannot-handle-a-.patch (text/plain), 3.41 KB, created by
Kyle M Hall (khall)
on 2017-12-14 15:34:01 UTC
(
hide
)
Description:
Bug 19813 - MarcItemFieldsToOrder cannot handle a tag not existing
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-12-14 15:34:01 UTC
Size:
3.41 KB
patch
obsolete
>From 1f006604dcab9d2d781ec732516428a5df337408 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 14 Dec 2017 10:31:17 -0500 >Subject: [PATCH] Bug 19813 - MarcItemFieldsToOrder cannot handle a tag not > existing > >MarcItemFieldsToOrder defines how Koha looks at tags in order records to generate item data. > >Let's look at a simplified case: >homebranch: 955$a >holdingbranch: 956$a > >So, here we are looking at 955 for the home branch, and 956 for the holding branch. So, it should make sense that Koha requires that these fields exist in equal number in the record. That is, for each 955, there should be a corresponding 956. > >Let's look at a different case: >homebranch: 946$a|975$a >holdingbranch: 946$a|975$a > >In this case, we are using the fallback behavior. VendorA stores the branch data in 946, and VendorB stores it in 975. This seems like it would work, but it won't! That's because Koha is expecting there to be the same number of 946's as there are 975's! In reality, the VendorA records will have a number of 946's, and *zero* 975's. The inverse will be true for VendorB. > >Koha should be able to skip those tags that simply don't exist in the record. > >Test Plan: >1) Set MarcItemFieldsToOrder to something like: >homebranch: 946$a|975$a >holdingbranch: 946$a|975$a >budget_code: 946$f|975$f >itype: 946$y|975$y >notforloan: 946$l|975$l >ccode: 946$t|975$c >quantity: 946$q|975$q >price: 946$p|975$p >itemcallnumber: 946$n|975$n >loc: 946$c|975$t >2) Create a record using only the 975 tag for item building data >3) Import the record into Koha >4) Create a basket >5) Attempt to add the record to the basket >6) Note the unequal fields error >7) Apply this patch >8) Reload the page >9) No error! >--- > acqui/addorderiso2709.pl | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index 0e0793b..5b13afd 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -687,18 +687,21 @@ sub get_infos_syspref { > > sub equal_number_of_fields { > my ($tags_list, $record) = @_; >- my $refcount = 0; >- my $count = 0; >+ my $tag_fields_count; > for my $tag (@$tags_list) { >- return -1 if $count != $refcount; >- $count = 0; >- for my $field ($record->field($tag)) { >- $count++; >+ my @fields = $record->field($tag); >+ $tag_fields_count->{$tag} = scalar @fields; >+ } >+ >+ my $tags_count; >+ foreach my $key ( keys %$tag_fields_count ) { >+ if ( $tag_fields_count->{$key} > 0 ) { # Having 0 of a field is ok >+ $tags_count //= $tag_fields_count->{$key}; # Start with the count from the first occurrance >+ return -1 if $tag_fields_count->{$key} != $tags_count; # All counts of various fields should be equal if they exist > } >- $refcount = $count if ($refcount == 0); > } >- return -1 if $count != $refcount; >- return $count; >+ >+ return $tags_count; > } > > sub get_infos_syspref_on_item { >@@ -749,7 +752,7 @@ sub get_infos_syspref_on_item { > for my $field ( @fields ) { > my ( $f, $sf ) = split /\$/, $field; > next unless $f and $sf; >- my $v = $fields_hash->{$f}[$i]->subfield( $sf ); >+ my $v = $fields_hash->{$f}[$i] ? $fields_hash->{$f}[$i]->subfield( $sf ) : undef; > $r->{$field_name} = $v if (defined $v); > last if $yaml->{$field}; > } >-- >2.10.2
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 19813
:
69804
|
69830
|
70110