Skip to content
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

Remove env placeholder regexp #422

Merged
merged 1 commit into from
May 7, 2018
Merged

Remove env placeholder regexp #422

merged 1 commit into from
May 7, 2018

Conversation

B-Galati
Copy link
Collaborator

fix #356

This is an internal detail that is not covered by the BC policy of Symfony and can thus break on any version.
We now detect if env variable is used by checking the 3rd parameter of method ContainerBuilder::resolveEnvPlaceholders

Note that we still have an issue with profile option that is not resolved at runtime.

@B-Galati B-Galati force-pushed the fix-356 branch 3 times, most recently from f4d50c2 to fdec2b2 Compare April 28, 2018 11:33
fix snc#356

This is an internal detail that is not covered by the BC policy of Symfony and can thus break on any version
We now detect if env variable is used by checking the 3rd parameter of method ContainerBuilder::resolveEnvPlaceholders
@curry684
Copy link
Collaborator

Thanks! I'll see when I can test this soon-ish.

@B-Galati
Copy link
Collaborator Author

B-Galati commented May 3, 2018

@curry684 As a second step I would be very happy to merge SncRedisExtensionEnvTest and SncRedisExtensionTest tests into one and use file fixtures instead of string. It would make these tests more simple and easier to manage and it looks to be a common testing practice in Symfony Bundles to use file fixture to load some bundle config.

@curry684 curry684 self-assigned this May 3, 2018
@curry684 curry684 self-requested a review May 3, 2018 14:12
@curry684 curry684 merged commit 6b3d92f into snc:2.1 May 7, 2018
@curry684
Copy link
Collaborator

curry684 commented May 7, 2018

Thanks!

curry684 pushed a commit that referenced this pull request May 7, 2018
fix #356

This is an internal detail that is not covered by the BC policy of Symfony and can thus break on any version
We now detect if env variable is used by checking the 3rd parameter of method ContainerBuilder::resolveEnvPlaceholders

(cherry picked from commit 6b3d92f)
@tgalopin
Copy link

I am not sure to understand the details of this PR, but I think it broke my setup (Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name does not resolve).

I debugged a bit: as parseDsn isn't executed anymore if an environment variable is detected, RedisDsn::getHost now returns null when called. However, in https://github.com/snc/SncRedisBundle/blob/master/DependencyInjection/SncRedisExtension.php#L294 the code calls it to generate the service definition during build, which leads to the following generated code:

<?php

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;

// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'snc_redis.session.handler' shared service.

$a = new \Snc\RedisBundle\Client\Phpredis\Client(array('alias' => 'default'), ($this->privates['snc_redis.logger'] ?? $this->getSncRedis_LoggerService()));
$a->connect(NULL, 6379, 5);
$a->setOption(1, 0);

return $this->services['snc_redis.session.handler'] = new \Snc\RedisBundle\Session\Storage\Handler\RedisSessionHandler($a, $this->parameters['session.storage.options'], 'session', true, 150000);

As you can see, the client tries to connect to null as a host, which fails. I reverted for now (back to 2.1.2, which works) but I think this is a BC break. I am using the following configuration:

snc_redis:
    clients:
        default:
            type: phpredis
            alias: default
            dsn: 'redis://%env(REDIS_HOST)%'

    session:
        client: default

I can try to create a reproducer but I don't think it should be difficult to create one using a basic Symfony 4 project as it's a container build issue.

Thanks for this great bundle and your work in open-source :) !

@B-Galati
Copy link
Collaborator Author

I confirm the issue, it happened only with phpredis ; which always use hardcoded env placeholders in fact :

Instead we should use a sort of Snc\RedisBundle\Factory\EnvParametersFactory for phpredis as well.

I guess the issue should be reopened too.

@curry684
Copy link
Collaborator

Reopened #356

@B-Galati
Copy link
Collaborator Author

@curry684 @tgalopin I'll try to make a fix in coming weeks

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

Successfully merging this pull request may close these issues.

None yet

3 participants