Bug 14932: Do not call can_edit_subscription with an empty value
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 11 Apr 2017 13:31:49 +0000 (10:31 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 13 Apr 2017 12:31:47 +0000 (08:31 -0400)
ref($sub) eq 'ARRAY' should always be true, what we want is to call
can_edit_subscription if there is at least 1 serial for this
subscription.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Serials.pm

index 040fe61..c1316f2 100644 (file)
@@ -343,7 +343,7 @@ sub GetFullSubscription {
     my $sth = $dbh->prepare($query);
     $sth->execute($subscriptionid);
     my $subscriptions = $sth->fetchall_arrayref( {} );
-    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if ref($subscriptions) eq 'ARRAY';
+    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if scalar @$subscriptions;
     for my $subscription ( @$subscriptions ) {
         $subscription->{cannotedit} = $cannotedit;
     }
@@ -503,7 +503,7 @@ sub GetFullSubscriptionsFromBiblionumber {
     my $sth = $dbh->prepare($query);
     $sth->execute($biblionumber);
     my $subscriptions = $sth->fetchall_arrayref( {} );
-    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if ref($subscriptions) eq 'ARRAY';
+    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if scalar @$subscriptions;
     for my $subscription ( @$subscriptions ) {
         $subscription->{cannotedit} = $cannotedit;
     }