Bug 8435: (follow-up) make SearchSubscriptions handle lack of userenv
authorGalen Charlton <gmc@esilibrary.com>
Thu, 31 Oct 2013 15:37:00 +0000 (15:37 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 31 Oct 2013 15:37:00 +0000 (15:37 +0000)
This patch allows t/db_dependent/Bookseller.t to pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Serials.pm

index da876e2..5256b13 100644 (file)
@@ -711,8 +711,9 @@ sub SearchSubscriptions {
     for my $subscription ( @$results ) {
         $subscription->{cannotedit} = not can_edit_subscription( $subscription );
         $subscription->{cannotdisplay} =
-            ( C4::Context->preference("IndependentBranches")
-                and $subscription->{branchcode} ne C4::Context->userenv->{'branch'} ) ? 1 : 0;
+            ( C4::Context->preference("IndependentBranches") &&
+              C4::Context->userenv &&
+              $subscription->{branchcode} ne C4::Context->userenv->{'branch'} ) ? 1 : 0;
     }
 
     return @$results;