Skip to content

Commit b703991

Browse files
committed
[redis] PR-515 fixes
1 parent 9f3e2f0 commit b703991

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

PRedis.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class PRedis implements Redis
2626
public function __construct(array $config)
2727
{
2828
$this->config = $this->config = array_replace([
29+
'scheme' => null,
2930
'host' => null,
3031
'port' => null,
3132
'pass' => null,

PhpRedis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PhpRedis implements Redis
2020
public function __construct(array $config)
2121
{
2222
$this->config = array_replace([
23+
'scheme' => null,
2324
'host' => null,
2425
'port' => null,
2526
'pass' => null,
@@ -73,6 +74,10 @@ public function connect(): void
7374
return;
7475
}
7576

77+
if ('rediss' == $this->config['scheme']) {
78+
throw new \LogicException('The phpredis extension does not support secured connections. Try to use predis library as vendor.');
79+
}
80+
7681
$this->redis = new \Redis();
7782

7883
if ($this->config['persisted']) {

RedisConnectionFactory.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ public function __construct($config = 'redis:')
6565
}
6666

6767
$this->config = array_replace($this->defaultConfig(), $config);
68-
$vendor = $this->config['vendor'];
6968

7069
$supportedVendors = ['predis', 'phpredis', 'custom'];
71-
if (false == in_array($vendor, $supportedVendors, true)) {
70+
if (false == in_array($this->config['vendor'], $supportedVendors, true)) {
7271
throw new \LogicException(sprintf(
7372
'Unsupported redis vendor given. It must be either "%s". Got "%s"',
7473
implode('", "', $supportedVendors),
75-
$vendor
74+
$this->config['vendor']
7675
));
7776
}
7877
}
@@ -122,10 +121,8 @@ private function createRedis(): Redis
122121

123122
private function parseDsn(string $dsn): array
124123
{
125-
$unsupportedError = 'The given DSN "%s" is not supported. Must start with "redis:".';
126-
127124
if ((false === strpos($dsn, 'redis:')) and (false === strpos($dsn, 'rediss:'))) {
128-
throw new \LogicException(sprintf($unsupportedError, $dsn));
125+
throw new \LogicException(sprintf('The given DSN "%s" is not supported. Must start with "redis:" or "rediss:".', $dsn));
129126
}
130127

131128
if (false === $config = parse_url($dsn)) {
@@ -143,18 +140,6 @@ private function parseDsn(string $dsn): array
143140
$config = array_replace($queryConfig, $config);
144141
}
145142

146-
if (isset($config['vendor'])) {
147-
$vendor = $config['vendor'];
148-
} else {
149-
$vendor = "";
150-
}
151-
152-
153-
//predis additionaly supports tls as scheme, but it must remain in the $config array
154-
if ($vendor!='predis') {
155-
if ($config['scheme']!='redis') throw new \LogicException(sprintf($unsupportedError, $dsn));
156-
unset($config['scheme']);
157-
}
158143
unset($config['query']);
159144

160145
$config['lazy'] = empty($config['lazy']) ? false : true;

0 commit comments

Comments
 (0)