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

[Cache] fix trying to load Memcached before checking we can #49395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Cache] fix trying to load Memcached before checking we can
  • Loading branch information
nicolas-grekas committed Feb 15, 2023
commit 818fdcb8d1d2cfa9bfd92906edebf7e3961f024f
16 changes: 4 additions & 12 deletions 16 src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ class MemcachedAdapter extends AbstractAdapter

protected $maxIdLength = 250;

private const DEFAULT_CLIENT_OPTIONS = [
'persistent_id' => null,
'username' => null,
'password' => null,
\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP,
];

private $marshaller;
private $client;
private $lazyClient;
Expand Down Expand Up @@ -106,10 +99,9 @@ public static function createConnection($servers, array $options = [])
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::DEFAULT_CLIENT_OPTIONS;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];
$client = new \Memcached($options['persistent_id'] ?? null);
$username = $options['username'] ?? null;
$password = $options['password'] ?? null;

// parse any DSN in $servers
foreach ($servers as $i => $dsn) {
Expand Down Expand Up @@ -199,7 +191,7 @@ public static function createConnection($servers, array $options = [])
$options[\constant('Memcached::OPT_'.$name)] = $value;
}
}
$client->setOptions($options);
$client->setOptions($options + [\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]);

// set client's servers, taking care of persistent connections
if (!$client->isPristine()) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.