Skip to content

Commit

Permalink
Predis: Fix specifying password via options instead of DSN
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Dec 31, 2022
1 parent 1dd46f1 commit 4c81b59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Factory/PredisParametersFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Predis\Connection\ParametersInterface;
use Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn;

use function array_filter;
use function array_merge;
use function is_a;
use function sprintf;
Expand Down Expand Up @@ -62,6 +63,6 @@ private static function parseDsn(RedisDsn $dsn): array
$options['alias'] = $dsn->getAlias();
}

return $options;
return array_filter($options, static fn ($value) => $value !== null);
}
}
16 changes: 13 additions & 3 deletions tests/Factory/PredisParametersFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function createDp(): array
],
[
'redis://localhost?alias=master',
'Predis\Connection\Parameters',
Parameters::class,
['replication' => true],
[
'scheme' => 'tcp',
Expand All @@ -98,7 +98,7 @@ public function createDp(): array
],
[
'redis://localhost?alias=connection_alias',
'Predis\Connection\Parameters',
Parameters::class,
[
'replication' => true,
'alias' => 'client_alias',
Expand All @@ -116,13 +116,23 @@ public function createDp(): array
],
[
'redis://localhost/0',
'Predis\Connection\Parameters',
Parameters::class,
['persistent' => true],
[
'persistent' => true,
'database' => 0,
],
],

[
'redis://localhost',
Parameters::class,
['database' => 11, 'password' => 'pass'],
[
'database' => 11,
'password' => 'pass',
],
],
];
}

Expand Down

0 comments on commit 4c81b59

Please sign in to comment.