Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c111bd

Browse filesBrowse files
minor #34290 [DI] Remove LazyString from 4.4, before adding back to the String component (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [DI] Remove LazyString from 4.4, before adding back to the String component | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - In #34190 I'm proposing to move LazyString to the Service contracts, but String might be a better fit actually. Let's remove the class from 4.4 where it's not really needed, and add it back on 5.0 in the String component. Commits ------- b1a3ee7 [DI] Remove LazyString from 4.4, before adding back to the String component
2 parents f459fd0 + b1a3ee7 commit 7c111bd
Copy full SHA for 7c111bd

File tree

10 files changed

+9
-255
lines changed
Filter options

10 files changed

+9
-255
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,9 +1476,13 @@ private function registerSecretsConfiguration(array $config, ContainerBuilder $c
14761476
}
14771477

14781478
if ($config['decryption_env_var']) {
1479-
$container->getDefinition('secrets.decryption_key')->replaceArgument(1, $config['decryption_env_var']);
1479+
if (!preg_match('/^(?:\w*+:)*+\w++$/', $config['decryption_env_var'])) {
1480+
throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.', $config['decryption_env_var']));
1481+
}
1482+
1483+
$container->getDefinition('secrets.vault')->replaceArgument(1, "%env({$config['decryption_env_var']})%");
14801484
} else {
1481-
$container->removeDefinition('secrets.decryption_key');
1485+
$container->getDefinition('secrets.vault')->replaceArgument(1, null);
14821486
}
14831487
}
14841488

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/secrets.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/secrets.xml
+1-19Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,7 @@
88
<service id="secrets.vault" class="Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault">
99
<tag name="container.env_var_loader" />
1010
<argument>%kernel.project_dir%/config/secrets/%kernel.environment%</argument>
11-
<argument type="service" id="secrets.decryption_key" on-invalid="ignore" />
12-
</service>
13-
14-
<!--
15-
LazyString::fromCallable() is used as a wrapper to lazily read the SYMFONY_DECRYPTION_SECRET var from the env.
16-
By overriding this service and using the same strategy, the decryption key can be fetched lazily from any other service if needed.
17-
-->
18-
<service id="secrets.decryption_key" class="Symfony\Component\DependencyInjection\LazyString">
19-
<factory class="Symfony\Component\DependencyInjection\LazyString" method="fromCallable" />
20-
<argument type="service">
21-
<service class="Closure">
22-
<factory class="Closure" method="fromCallable" />
23-
<argument type="collection">
24-
<argument type="service" id="service_container" />
25-
<argument>getEnv</argument>
26-
</argument>
27-
</service>
28-
</argument>
29-
<argument>base64:default::SYMFONY_DECRYPTION_SECRET</argument>
11+
<argument>%env(base64:default::SYMFONY_DECRYPTION_SECRET)%</argument>
3012
</service>
3113

3214
<service id="secrets.local_vault" class="Symfony\Bundle\FrameworkBundle\Secrets\DotenvVault">

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php
-9Lines changed: 0 additions & 9 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_env_var.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_env_var.xml
-17Lines changed: 0 additions & 17 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_env_var.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_env_var.yml
-6Lines changed: 0 additions & 6 deletions
This file was deleted.

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+2-16Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
use Symfony\Component\DependencyInjection\ContainerInterface;
3535
use Symfony\Component\DependencyInjection\Definition;
3636
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
37-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
37+
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
3838
use Symfony\Component\DependencyInjection\Reference;
3939
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4040
use Symfony\Component\HttpClient\ScopingHttpClient;
@@ -1403,20 +1403,6 @@ public function testCacheDefaultRedisProvider()
14031403
$this->assertSame($redisUrl, $url);
14041404
}
14051405

1406-
public function testCacheDefaultRedisProviderWithEnvVar()
1407-
{
1408-
$container = $this->createContainerFromFile('cache_env_var');
1409-
1410-
$redisUrl = 'redis://paas.com';
1411-
$providerId = '.cache_connection.'.ContainerBuilder::hash($redisUrl);
1412-
1413-
$this->assertTrue($container->hasDefinition($providerId));
1414-
1415-
$url = $container->getDefinition($providerId)->getArgument(0);
1416-
1417-
$this->assertSame($redisUrl, $url);
1418-
}
1419-
14201406
public function testCachePoolServices()
14211407
{
14221408
$container = $this->createContainerFromFile('cache', [], true, false);
@@ -1584,7 +1570,7 @@ public function testMailer(): void
15841570

15851571
protected function createContainer(array $data = [])
15861572
{
1587-
return new ContainerBuilder(new ParameterBag(array_merge([
1573+
return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([
15881574
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
15891575
'kernel.bundles_metadata' => ['FrameworkBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..']],
15901576
'kernel.cache_dir' => __DIR__,

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CHANGELOG
1414
* made singly-implemented interfaces detection be scoped by file
1515
* added ability to define a static priority method for tagged service
1616
* added support for improved syntax to define method calls in Yaml
17-
* added `LazyString` for lazy computation of string values injected into services
1817
* made the `%env(base64:...)%` processor able to decode base64url
1918
* added ability to choose behavior of decorations on non existent decorated services
2019

‎src/Symfony/Component/DependencyInjection/LazyString.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyString.php
-112Lines changed: 0 additions & 112 deletions
This file was deleted.

‎src/Symfony/Component/DependencyInjection/Tests/LazyStringTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/LazyStringTest.php
-72Lines changed: 0 additions & 72 deletions
This file was deleted.

‎src/Symfony/Component/DependencyInjection/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/composer.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"require-dev": {
2424
"symfony/yaml": "^3.4|^4.0|^5.0",
2525
"symfony/config": "^4.3|^5.0",
26-
"symfony/error-handler": "^4.4|^5.0",
2726
"symfony/expression-language": "^3.4|^4.0|^5.0"
2827
},
2928
"suggest": {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.