]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1445041 - if memcached server does not end with a port, append :11211
authorDylan William Hardison <dylan@hardison.net>
Mon, 12 Mar 2018 23:51:47 +0000 (19:51 -0400)
committerGitHub <noreply@github.com>
Mon, 12 Mar 2018 23:51:47 +0000 (19:51 -0400)
Bugzilla/Memcached.pm

index 9868dfb423380ebdd0a62ea3105b04b3bdb4ed61..388d8c5ed833fa474553388ee640b7f96cfcf7bc 100644 (file)
@@ -16,7 +16,7 @@ use Log::Log4perl qw(:easy);
 use Bugzilla::Error;
 use Scalar::Util qw(blessed);
 use List::Util qw(sum);
-use Bugzilla::Util qw(trick_taint);
+use Bugzilla::Util qw(trick_taint trim);
 use URI::Escape;
 use Encode;
 use Sys::Syslog qw(:DEFAULT);
@@ -37,7 +37,7 @@ sub _new {
         $self->{namespace} = Bugzilla->localconfig->{memcached_namespace};
         TRACE("connecting servers: $servers, namespace: $self->{namespace}");
         $self->{memcached} = Cache::Memcached::Fast->new({
-            servers   => [ split(/[, ]+/, $servers) ],
+            servers   => [ _parse_memcached_server_list($servers) ],
             namespace => $self->{namespace},
             max_size  => 1024 * 1024 * 4,
         });
@@ -48,6 +48,13 @@ sub _new {
     return bless($self, $class);
 }
 
+sub _parse_memcached_server_list {
+    my ($server_list) = @_;
+    my @servers = split(/[, ]+/, trim($server_list));
+
+    return map { /:[0-9]+$/s ? $_ : "$_:11211" } @servers;
+}
+
 sub enabled {
     return $_[0]->{memcached} ? 1 : 0;
 }