minor #31678 [Config] Removed env var support with cannotBeEmpty() (ro0NL)
This PR was merged into the 5.0-dev branch.
Discussion
----------
[Config] Removed env var support with cannotBeEmpty()
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
See #28858
Commits
-------
ec27d7486d
[Config] Removed env var support with cannotBeEmpty()
This commit is contained in:
commit
a2f2769748
@ -84,14 +84,13 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface
|
||||
// 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)) {
|
||||
|
@ -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;
|
||||
@ -229,13 +230,15 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = [
|
||||
@ -243,8 +246,6 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->doProcess($container);
|
||||
|
||||
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
||||
}
|
||||
|
||||
public function testPartialEnvWhichCannotBeEmptyForScalarNode(): void
|
||||
|
Reference in New Issue
Block a user