8000 [Config] Removed env var support with cannotBeEmpty() by ro0NL · Pull Request #31678 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] Removed env var support with cannotBeEmpty() #31678

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

Merged
merged 1 commit into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/Symfony/Component/Config/Definition/VariableNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@ protected function finalizeValue($value)
// deny environment variables only when using custom validators
// this avoids ever passing an empty value to final validation closures
if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
@trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), E_USER_DEPRECATED);
// $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath(), json_encode($value)));
// if ($hint = $this->getInfo()) {
// $e->addHint($hint);
// }
// $e->setPath($this->getPath());
//
// throw $e;
$e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath(), json_encode($value)));
if ($hint = $this->getInfo()) {
$e->addHint($hint);
}
$e->setPath($this->getPath());

throw $e;
}

if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Compiler;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
Expand Down Expand Up @@ -229,22 +230,22 @@ public function testEmptyEnvWhichCannotBeEmptyForScalarNode(): void
}

/**
* NOT LEGACY (test exception in 5.0).
*
* @group legacy
* @expectedDeprecation Setting path "env_extension.scalar_node_not_empty_validated" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated.
*/
public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation(): void
{
if (!method_exists(ParentNodeDefinitionInterface::class, 'getChildNodeDefinitions')) {
$this->markTestSkipped('symfony/config >=5.0 is required.');
}

$container = new ContainerBuilder();
$container->registerExtension($ext = new EnvExtension());
$container->prependExtensionConfig('env_extension', $expected = [
'scalar_node_not_empty_validated' => '%env(SOME)%',
]);

$this->doProcess($container);

$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
}

public function testPartialEnvWhichCannotBeEmptyForScalarNode(): void
Expand Down
0