Bug 17833: Add a warning if memcached init failed
authorOlli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
Mon, 2 Jan 2017 11:01:02 +0000 (13:01 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 9 Jan 2018 20:23:15 +0000 (17:23 -0300)
If memcached or the connection to it is misconfigured, show simple warnings to help
identify the problem.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Cache.pm

index 5af8c0e..5bab842 100644 (file)
@@ -139,9 +139,13 @@ sub _initialize_memcached {
             utf8               => 1,
         }
     );
+
     # Ensure we can actually talk to the memcached server
     my $ismemcached = $memcached->set('ismemcached','1');
-    return $self unless $ismemcached;
+    unless ($ismemcached) { #Value is undefined or False, so there was an error with the server, the connection to it, or a protocol error
+        warn "Connection to the memcached servers '@servers' failed. Are the unix socket permissions set properly? Is the host reachable?";
+        return $self;
+    }
     $self->{'memcached_cache'} = $memcached;
     return $self;
 }