8000 [FrameworkBundle] Deprecate not setting some options · Jean-Beru/symfony@7f9998e · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f9998e

Browse files
Jean-Berunicolas-grekas
authored andcommitted
[FrameworkBundle] Deprecate not setting some options
1 parent 951b11e commit 7f9998e

File tree

311 files changed

+869
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+869
-131
lines changed

UPGRADE-6.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ FrameworkBundle
8585
* [BC break] Add native return type to `Translator` and to `Application::reset()`
8686
* Deprecate the integration of Doctrine annotations, either uninstall the `doctrine/annotations` package or disable
8787
the integration by setting `framework.annotations` to `false`
88+
* Deprecate not setting the `framework.handle_all_throwables` config option; it will default to `true` in 7.0
89+
* Deprecate not setting the `framework.php_errors.log` config option; it will default to `true` in 7.0
90+
* Deprecate not setting the `framework.session.cookie_secure` config option; it will default to `auto` in 7.0
91+
* Deprecate not setting the `framework.session.cookie_samesite` config option; it will default to `lax` in 7.0
92+
* Deprecate not setting the `framework.session.handler_id` config option; it will default to `session.handler.native_file` when `framework.session.save_path` is set or `null` otherwise in 7.0
8893

8994
HttpFoundation
9095
--------------

src/Symfony/Bridge/PsrHttpMessage/Tests/Fixtures/App/Kernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ protected function configureContainer(ContainerConfigurator $container): void
5252
'test' => true,
5353
'annotations' => false,
5454
'http_method_override' => false,
55+
'handle_all_throwables' => true,
56+
'php_errors' => ['log' => true],
5557
]);
5658

5759
$container->services()

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ CHANGELOG
1212
* Add `DomCrawlerAssertionsTrait::assertAnySelectorTextNotContains(string $selector, string $text)`
1313
* Deprecate `EnableLoggerDebugModePass`, use argument `$debug` of HttpKernel's `Logger` instead
1414
* Deprecate `AddDebugLogProcessorPass::configureLogger()`, use HttpKernel's `DebugLoggerConfigurator` instead
15+
* Deprecate not setting the `framework.handle_all_throwables` config option; it will default to `true` in 7.0
16+
* Deprecate not setting the `framework.php_errors.log` config option; it will default to `true` in 7.0
17+
* Deprecate not setting the `framework.session.cookie_secure` config option; it will default to `auto` in 7.0
18+
* Deprecate not setting the `framework.session.cookie_samesite` config option; it will default to `lax` in 7.0
19+
* Deprecate not setting the `framework.session.handler_id` config option; it will default to `session.handler.native_file` when `framework.session.save_path` is set or `null` otherwise in 7.0
1520

1621
6.3
1722
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public function getConfigTreeBuilder(): TreeBuilder
9090

9191
$v['http_method_override'] = true;
9292
}
93+
if (!isset($v['handle_all_throwables'])) {
94+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.handle_all_throwables" config option is deprecated. It will default to "true" in 7.0.');
95+
}
9396

9497
return $v;
9598
})
@@ -655,13 +658,34 @@ private function addRouterSection(ArrayNodeDefinition $rootNode): void
655658
private function addSessionSection(ArrayNodeDefinition $rootNode): void
656659
{
657660
$rootNode
661+
->validate()
662+
->always(function (array $v): array {
663+
if ($v['session']['enabled']) {
664+
if (!\array_key_exists('cookie_secure', $v['session'])) {
665+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.session.cookie_secure" config option is deprecated. It will default to "auto" in 7.0.');
666+
}
667+
668+
if (!\array_key_exists('cookie_samesite', $v['session'])) {
669+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.session.cookie_samesite" config option is deprecated. It will default to "lax" in 7.0.');
670+
}
671+
672+
if (!\array_key_exists('handler_id', $v['session'])) {
673+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.session.handler_id" config option is deprecated. It will default to "session.handler.native_file" when "framework.session.save_path" is set or "null" otherwise in 7.0.');
674+
}
675+
}
676+
677+
$v['session'] += ['cookie_samesite' => null, 'handler_id' => 'session.handler.native_file'];
678+
679+
return $v;
680+
})
681+
->end()
658682
->children()
659683
->arrayNode('session')
660684
->info('session configuration')
661685
->canBeEnabled()
662686
->children()
663687
->scalarNode('storage_factory_id')->defaultValue('session.storage.factory.native')->end()
664-
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
688+
->scalarNode('handler_id')->end()
665689
->scalarNode('name')
666690
->validate()
667691
->ifTrue(function ($v) {
@@ -677,7 +701,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode): void
677701
->scalarNode('cookie_domain')->end()
678702
->enumNode('cookie_secure')->values([true, false, 'auto'])->end()
679703
->booleanNode('cookie_httponly')->defaultTrue()->end()
680-
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->defaultNull()->end()
704+
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->end()
681705
->booleanNode('use_cookies')->end()
682706
->scalarNode('gc_divisor')->end()
683707
->scalarNode('gc_probability')->defaultValue(1)->end()
@@ -1264,6 +1288,17 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
12641288
private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
12651289
{
12661290
$rootNode
1291+
->validate()
1292+
->always(function (array $v): array {
1293+
if (!\array_key_exists('log', $v['php_errors'])) {
1294+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.php_errors.log" config option is deprecated. It will default to "true" in 7.0.');
1295+
1296+
$v['php_errors']['log'] = $this->debug;
1297+
}
1298+
1299+
return $v;
1300+
})
1301+
->end()
12671302
->children()
12681303
->arrayNode('php_errors')
12691304
->info('PHP errors handling configuration')
@@ -1272,7 +1307,6 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
12721307
->variableNode('log')
12731308
->info('Use the application logger instead of the PHP logger for logging PHP errors.')
12741309
->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants, or an array mapping E_* constants to log levels.')
1275-
->defaultValue($this->debug)
12761310
->treatNullLike($this->debug)
12771311
->beforeNormalization()
12781312
->ifArray()

src/Symfony/Bundle/FrameworkBundle/Tests/Command/AboutCommand/Fixture/TestAppKernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3636
$container->loadFromExtension('framework', [
3737
'annotations' => false,
3838
'http_method_override' => false,
39+
'handle_all_throwables' => true,
40+
'php_errors' => ['log' => true],
3941
]);
4042
});
4143
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
framework:
22
annotations: false
33
http_method_override: false
4+
handle_all_throwables: true
5+
php_errors:
6+
log: true
47
secret: test

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ class ConfigurationTest extends TestCase
3535
public function testDefaultConfig()
3636
{
3737
$processor = new Processor();
38-
$config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t', 'serializer' => ['default_context' => ['foo' => 'bar']]]]);
38+
$config = $processor->processConfiguration(new Configuration(true), [[
39+
'http_method_override' => false,
40+
'handle_all_throwables' => true,
41+
'php_errors' => ['log' => true],
42+
'secret' => 's3cr3t',
43+
'serializer' => ['default_context' => ['foo' => 'bar']],
44+
]]);
3945

4046
$this->assertEquals(self::getBundleDefaultConfig(), $config);
4147
}
@@ -59,7 +65,12 @@ public function testInvalidSessionName($sessionName)
5965
$processor = new Processor();
6066
$processor->processConfiguration(
6167
new Configuration(true),
62-
[['http_method_override' => false, 'session' => ['name' => $sessionName]]]
68+
[[
69+
'http_method_override' => false,
70+
'handle_all_throwables' => true,
71+
'php_errors' => ['log' => true],
72+
'session' => ['name' => $sessionName, 'cookie_secure' => 'auto', 'cookie_samesite' => 'lax'],
73+
]]
6374
);
6475
}
6576

@@ -79,7 +90,12 @@ public function testAssetsCanBeEnabled()
7990
{
8091
$processor = new Processor();
8192
$configuration = new Configuration(true);
82-
$config = $processor->processConfiguration($configuration, [['http_method_override' => false, 'assets' => null]]);
93+
$config = $processor->processConfiguration($configuration, [[
94+
'http_method_override' => false,
95+
'handle_all_throwables' => true,
96+
'php_errors' => ['log' => true],
97+
'assets' => null,
98+
]]);
8399

84100
$defaultConfig = [
85101
'enabled' => true,
@@ -100,7 +116,12 @@ public function testAssetMapperCanBeEnabled()
100116
{
101117
$processor = new Processor();
102118
$configuration = new Configuration(true);
103-
$config = $processor->processConfiguration($configuration, [['http_method_override' => false, 'asset_mapper' => null]]);
119+
$config = $processor->processConfiguration($configuration, [[
120+
'http_method_override' => false,
121+
'handle_all_throwables' => true,
122+
'php_errors' => ['log' => true],
123+
'asset_mapper' => null,
124+
]]);
104125

105126
$defaultConfig = [
106127
'enabled' => true,
@@ -130,6 +151,8 @@ public function testValidAssetsPackageNameConfiguration($packageName)
130151
$config = $processor->processConfiguration($configuration, [
131152
[
132153
'http_method_override' => false,
154+
'handle_all_throwables' => true,
155+
'php_errors' => ['log' => true],
133156
'assets' => [
134157
'packages' => [
135158
$packageName => [],
@@ -163,6 +186,8 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess
163186
$processor->processConfiguration($configuration, [
164187
[
165188
'http_method_override' => false,
189+
'handle_all_throwables' => true,
190+
'php_errors' => ['log' => true],
166191
'assets' => $assetConfig,
167192
],
168193
]);
@@ -211,6 +236,8 @@ public function testValidLockConfiguration($lockConfig, $processedConfig)
211236
$config = $processor->processConfiguration($configuration, [
212237
[
213238
'http_method_override' => false,
239+
'handle_all_throwables' => true,
240+
'php_errors' => ['log' => true],
214241
'lock' => $lockConfig,
215242
],
216243
]);
@@ -272,12 +299,16 @@ public function testLockMergeConfigs()
272299
$config = $processor->processConfiguration($configuration, [
273300
[
274301
'http_method_override' => false,
302+
'handle_all_throwables' => true,
303+
'php_errors' => ['log' => true],
275304
'lock' => [
276305
'payload' => 'flock',
277306
],
278307
],
279308
[
280309
'http_method_override' => false,
310+
'handle_all_throwables' => true,
311+
'php_errors' => ['log' => true],
281312
'lock' => [
282313
'payload' => 'semaphore',
283314
],
@@ -305,6 +336,8 @@ public function testValidSemaphoreConfiguration($semaphoreConfig, $processedConf
305336
$config = $processor->processConfiguration($configuration, [
306337
[
307338
'http_method_override' => false,
339+
'handle_all_throwables' => true,
340+
'php_errors' => ['log' => true],
308341
'semaphore' => $semaphoreConfig,
309342
],
310343
]);
@@ -358,6 +391,8 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau
358391
$processor->processConfiguration($configuration, [
359392
'framework' => [
360393
'http_method_override' => false,
394+
'handle_all_throwables' => true,
395+
'php_errors' => ['log' => true],
361396
'messenger' => [
362397
'default_bus' => null,
363398
'buses' => [
@@ -376,6 +411,8 @@ public function testBusMiddlewareDontMerge()
376411
$config = $processor->processConfiguration($configuration, [
377412
[
378413
'http_method_override' => false,
414+
'handle_all_throwables' => true,
415+
'php_errors' => ['log' => true],
379416
'messenger' => [
380417
'default_bus' => 'existing_bus',
381418
'buses' => [
@@ -391,6 +428,8 @@ public function testBusMiddlewareDontMerge()
391428
],
392429
[
393430
'http_method_override' => false,
431+
'handle_all_throwables' => true,
432+
'php_errors' => ['log' => true],
394433
'messenger' => [
395434
'buses' => [
396435
'common_bus' => [
@@ -440,6 +479,8 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
440479
$processor->processConfiguration($configuration, [
441480
[
442481
'http_method_override' => false,
482+
'handle_all_throwables' => true,
483+
'php_errors' => ['log' => true],
443484
'messenger' => [
444485
'default_bus' => 'foo',
445486
'buses' => [
@@ -459,6 +500,8 @@ public function testLockCanBeDisabled()
459500
$config = $processor->processConfiguration($configuration, [
460501
[
461502
'http_method_override' => false,
503+
'handle_all_throwables' => true,
504+
'php_errors' => ['log' => true],
462505
'lock' => ['enabled' => false],
463506
],
464507
]);
@@ -477,6 +520,8 @@ public function testEnabledLockNeedsResources()
477520
$processor->processConfiguration($configuration, [
478521
[
479522
'http_method_override' => false,
523+
'handle_all_throwables' => true,
524+
'php_errors' => ['log' => true],
480525
'lock' => ['enabled' => true],
481526
],
482527
]);
@@ -486,6 +531,7 @@ protected static function getBundleDefaultConfig()
486531
{
487532
return [
488533
'http_method_override' => false,
534+
'handle_all_throwables' => true,
489535
'trust_x_sendfile_type_header' => false,
490536
'ide' => '%env(default::SYMFONY_IDE)%',
491537
'default_locale' => 'en',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
$container->loadFromExtension('framework', [
44
'annotations' => false,
55
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
68
'assets' => [
79
'version' => 'SomeVersionScheme',
810
'base_urls' => 'http://cdn.example.com',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
$container->loadFromExtension('framework', [
44
'annotations' => false,
55
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
68
'assets' => [
79
'enabled' => false,
810
],

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
$container->loadFromExtension('framework', [
44
'annotations' => false,
55
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
68
'assets' => [
79
'version_strategy' => 'assets.custom_version_strategy',
810
'base_urls' => 'http://cdn.example.com',

0 commit comments

Comments
 (0)
0