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

Redis ressource manager shouldn't check server not starting with '/' #6584

Closed
ghost opened this issue Aug 19, 2014 · 5 comments
Closed

Redis ressource manager shouldn't check server not starting with '/' #6584

ghost opened this issue Aug 19, 2014 · 5 comments

Comments

@ghost
Copy link

ghost commented Aug 19, 2014

In library/Zend/Cache/Storage/Adapter/RedisResourceManager.php on line 196, the normalize server function check if the server doesn't start with a slash.

if (strpos($server, '/') !== 0) {

Shouldn't it better check if there is a slash in the server variable?

@Ocramius
Copy link
Member

@steeve-christen could you convert this into a failing test case? I do not understand the consequences of what you are reporting: why is that check wrong?

@ghost
Copy link
Author

ghost commented Aug 20, 2014

If you give a server address without port (example.com), the test return true and try to parse the url

parse_url($server);

Error message would then be:

Notice: Undefined index: host
Exception: Missing required server host

It isn't the problem of a slash, but that the port is missing, isn't it?

Thank's for your answer.

@Martin-P
Copy link
Contributor

If you give a server address without port (example.com), the test return true and try to parse the url

When I use your suggestion (example.com) all works fine with this testcase:

public function testSetServerWithoutPort()
{
    $dummyResId = '1234567890';
    $server     = 'redis://example.com';

    $this->resourceManager->setServer($dummyResId, $server);

    $server = $this->resourceManager->getServer($dummyResId);

    $this->assertEquals('example.com', $server['host']);
}

You are using the latest version of ZF2 (2.3.2)? I see the parsing of the url is updated in the latest release via PR #6495.

@ghost
Copy link
Author

ghost commented Aug 21, 2014

I meant, if you use just example.com as bellow

$server = 'example.com';

Then, the test return true and try to parse the url which doesn't return a host:

var_dump(parse_url('redis://example.com'));
var_dump(parse_url('example.com/'));

return:

array (size=2)
    'scheme' => string 'redis' (length=5)
    'host' => string 'example.com' (length=11)

array (size=1)
    'path' => string 'example.com/' (length=12)

Yes I'm using 2.3.2.

@GeeH
Copy link

GeeH commented Jun 27, 2016

This issue has been closed as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants