Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f9312fd

Browse filesBrowse files
[Cache] fix trying to load Memcached before checking we can
1 parent 7f3e387 commit f9312fd
Copy full SHA for f9312fd

File tree

Expand file treeCollapse file tree

1 file changed

+5
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-12
lines changed

‎src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
+5-12Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ class MemcachedAdapter extends AbstractAdapter
3232

3333
protected $maxIdLength = 250;
3434

35-
private const DEFAULT_CLIENT_OPTIONS = [
36-
'persistent_id' => null,
37-
'username' => null,
38-
'password' => null,
39-
\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP,
40-
];
41-
4235
private $marshaller;
4336
private $client;
4437
private $lazyClient;
@@ -106,10 +99,9 @@ public static function createConnection($servers, array $options = [])
10699
}
107100
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
108101
try {
109-
$options += static::DEFAULT_CLIENT_OPTIONS;
110-
$client = new \Memcached($options['persistent_id']);
111-
$username = $options['username'];
112-
$password = $options['password'];
102+
$client = new \Memcached($options['persistent_id'] ?? null);
103+
$username = $options['username'] ?? null;
104+
$password = $options['password'] ?? null;
113105

114106
// parse any DSN in $servers
115107
foreach ($servers as $i => $dsn) {
@@ -180,6 +172,7 @@ public static function createConnection($servers, array $options = [])
180172
// set client's options
181173
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
182174
$options = array_change_key_case($options, \CASE_UPPER);
175+
183176
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
184177
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
185178
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
@@ -199,7 +192,7 @@ public static function createConnection($servers, array $options = [])
199192
$options[\constant('Memcached::OPT_'.$name)] = $value;
200193
}
201194
}
202-
$client->setOptions($options);
195+
$client->setOptions($options + [\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]);
203196

204197
// set client's servers, taking care of persistent connections
205198
if (!$client->isPristine()) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.