Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

RedisResourceManager breaks if being configured via StorageCacheAbstractServiceFactory/array and server key isn't first in options array #109

@rarog

Description

@rarog

I take the example from the docs to demonstrate the problem:

'caches' => array( 'Cache\Transient' => array( 'adapter' => 'redis', 'ttl' => 3600, 'options' => array( 'server' => array( 'host'=>'localhost', 'port' => 6379, 'timeout' => 2.5, ), 'database' => 5, 'password' => '', ), 'plugins' => array( 'exception_handler' => array( 'throw_exceptions' => false, ), 'serializer', ), ), ),

The relevant part is the options array.

'options' => array( 'server' => array( 'host'=>'localhost', 'port' => 6379, 'timeout' => 2.5, ), 'database' => 0, 'password' => '', ),
would work, but for example
'options' => array( 'database' => 0, 'server' => array( 'host'=>'localhost', 'port' => 6379, 'timeout' => 2.5, ), 'password' => '', ),
wouldn't.

All the setters in RedisResourceManager look if the id is already initialised, if not, every setter calls setResource with only his own parameter.
setResource merges this with the default array, which has empty array for the server key. At the end of the function setResource always calls normalizeServer, which checks if key host is set and throws an exception, if it's not.
As it is now, the code fails for every initialisation, where server key isn't the first inside the options array, because an exception is thrown.

I'm not making own fix via pull request, because this should be a design decision.

This problem also exists in the LTS 2.4 branch in exactly the same way.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions