Bug 10428: undefined check in add additem.pl
authorFridolyn SOMERS <fridolyn.somers@biblibre.com>
Fri, 7 Jun 2013 08:17:54 +0000 (10:17 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 3 Jul 2013 11:30:38 +0000 (04:30 -0700)
In additem.pl, in the code that generates item form you find:

@values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));

This patch adds the check of $itemrecord->field($tag) undef.
I did not found a way to test it because item tag is always defined
when editing an item, but it would be safer/prettier to add this check.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passed-QA-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
cataloguing/additem.pl

index a2eacef..36978bc 100755 (executable)
@@ -794,7 +794,7 @@ foreach my $tag ( keys %{$tagslib}){
         next if any { /^$tag$subtag$/ }  @fields;
 
         my @values = (undef);
-        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
+        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
         for my $value (@values){
             my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
             push (@loop_data, $subfield_data);