Bug 18443: Get rid of warning 'uninitialized value $user' in C4/Auth.pm
authorMarc Véron <veron@veron.ch>
Tue, 18 Apr 2017 07:21:45 +0000 (09:21 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 21 Apr 2017 14:57:50 +0000 (10:57 -0400)
When logging out from OPAC, plack-error.log log and/or opac-error.log
complain about 'uninitialized value $user' in C4/Auth.pm line 187. The
warning is not necessary, this patch removes it.

To test:
- try to trigger warning
- apply patch
- verify that warning no longer occurs
- prove t/db_dependent/Auth.t
- verifiy that SCO still behaves like before (especially if
  you break out from sco path)

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

index b5b7554..40b273a 100644 (file)
@@ -184,7 +184,7 @@ sub get_template_and_user {
 
     # If the user logged in is the SCO user and they try to go out of the SCO module, log the user out removing the CGISESSID cookie
     if ( $in->{type} eq 'opac' and $in->{template_name} !~ m|sco/| ) {
-        if (  C4::Context->preference('AutoSelfCheckID') && $user eq C4::Context->preference('AutoSelfCheckID') ) {
+        if ( $user && C4::Context->preference('AutoSelfCheckID') && $user eq C4::Context->preference('AutoSelfCheckID') ) {
             $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac', $in->{query} );
             my $cookie = $in->{query}->cookie(
                 -name     => 'CGISESSID',