From 50673b659b73b68f0ee396ef228ae2e124b7c094 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 14 Oct 2020 13:42:32 +0100 Subject: [PATCH] Bug 24786: (QA follow-up) Fix Registers Plugin For the QA script we do not set a userenv, so we result in a failure due to a lack of checking for userenv prior to using it. --- Koha/Template/Plugin/Registers.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Koha/Template/Plugin/Registers.pm b/Koha/Template/Plugin/Registers.pm index 313a2b11eb..05e0579544 100644 --- a/Koha/Template/Plugin/Registers.pm +++ b/Koha/Template/Plugin/Registers.pm @@ -84,14 +84,15 @@ Returns a list of all cash registers available that adhere to the passed filters sub all { my ( $self, $params ) = @_; - my $filters = $params->{filters}; + my $filters = $params->{filters} // {}; my $where; - $where->{branch} = C4::Context->userenv->{'branch'} + $where->{branch} = + C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef if $filters->{current_branch}; my $registers = Koha::Cash::Registers->search($where)->unblessed(); for my $register ( @{$registers} ) { $register->{selected} = ( defined( $self->session_register_id ) - && $register->{id} == $self->session_register_id ) ? 1 : 0; + && $register->{id} eq $self->session_register_id ) ? 1 : 0; } return $registers; -- 2.20.1