Skip to content

Commit 9b8f1e3

Browse files
minor #51428 [FrameworkBundle] Remove config deprecations (alexandre-daubois)
This PR was merged into the 7.0 branch. Discussion ---------- [FrameworkBundle] Remove config deprecations | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | - | License | MIT | Doc PR | Todo Follow-up of: - #51325 - #51357 Commits ------- 4fe6f5b [FrameworkBundle] Remove config deprecations
2 parents 63a11f4 + 4fe6f5b commit 9b8f1e3

File tree

5 files changed

+40
-94
lines changed

5 files changed

+40
-94
lines changed

UPGRADE-7.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ FrameworkBundle
202202
* Remove the integration of Doctrine annotations, use native attributes instead
203203
* Remove `EnableLoggerDebugModePass`, use argument `$debug` of HttpKernel's `Logger` instead
204204
* Remove `AddDebugLogProcessorPass::configureLogger()`, use HttpKernel's `DebugLoggerConfigurator` instead
205+
* Make the `framework.handle_all_throwables` config option default to `true`
206+
* Make the `framework.php_errors.log` config option default to `true`
207+
* Make the `framework.session.cookie_secure` config option default to `auto`
208+
* Make the `framework.session.cookie_samesite` config option default to `lax`
209+
* Make the `framework.session.handler_id` default to null if `save_path` is not set and to `session.handler.native_file` otherwise
210+
* Make the `framework.uid.default_uuid_version` config option default to `7`
211+
* Make the `framework.uid.time_based_uuid_version` config option default to `7`
212+
* Make the `framework.validation.email_validation_mode` config option default to `html5`
205213

206214
HttpFoundation
207215
--------------

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ CHANGELOG
1414
* Remove the integration of Doctrine annotations, use native attributes instead
1515
* Remove `EnableLoggerDebugModePass`, use argument `$debug` of HttpKernel's `Logger` instead
1616
* Remove `AddDebugLogProcessorPass::configureLogger()`, use HttpKernel's `DebugLoggerConfigurator` instead
17+
* Make the `framework.handle_all_throwables` config option default to `true`
18+
* Make the `framework.php_errors.log` config option default to `true`
19+
* Make the `framework.session.cookie_secure` config option default to `auto`
20+
* Make the `framework.session.cookie_samesite` config option default to `lax`
21+
* Make the `framework.session.handler_id` default to null if `save_path` is not set and to `session.handler.native_file` otherwise
22+
* Make the `framework.uid.default_uuid_version` config option default to `7`
23+
* Make the `framework.uid.time_based_uuid_version` config option default to `7`
24+
* Make the `framework.validation.email_validation_mode` config option default to `html5`
1725

1826
6.4
1927
---

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

Lines changed: 13 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ public function getConfigTreeBuilder(): TreeBuilder
8282
return $v;
8383
})
8484
->end()
85-
->validate()
86-
->always(function ($v) {
87-
if (!isset($v['handle_all_throwables'])) {
88-
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.');
89-
}
90-
91-
return $v;
92-
})
93-
->end()
9485
->fixXmlConfig('enabled_locale')
9586
->children()
9687
->scalarNode('secret')->end()
@@ -137,7 +128,7 @@ public function getConfigTreeBuilder(): TreeBuilder
137128
->scalarNode('error_controller')
138129
->defaultValue('error_controller')
139130
->end()
140-
->booleanNode('handle_all_throwables')->info('HttpKernel will handle all kinds of \Throwable')->end()
131+
->booleanNode('handle_all_throwables')->info('HttpKernel will handle all kinds of \Throwable')->defaultTrue()->end()
141132
->end()
142133
;
143134

@@ -649,38 +640,15 @@ private function addRouterSection(ArrayNodeDefinition $rootNode): void
649640
private function addSessionSection(ArrayNodeDefinition $rootNode): void
650641
{
651642
$rootNode
652-
->validate()
653-
->always(function (array $v): array {
654-
if ($v['session']['enabled']) {
655-
if (!\array_key_exists('cookie_secure', $v['session'])) {
656-
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.');
657-
}
658-
659-
if (!\array_key_exists('cookie_samesite', $v['session'])) {
660-
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.');
661-
}
662-
663-
if (!\array_key_exists('handler_id', $v['session']) && !\array_key_exists('handler_id', $v['save_path'])) {
664-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting either "framework.session.handler_id" or "save_path" config options is deprecated; "handler_id" will default to null in 7.0 if "save_path" is not set and to "session.handler.native_file" otherwise.');
665-
}
666-
}
667-
668-
$v['session'] += [
669-
'cookie_samesite' => null,
670-
'handler_id' => 'session.handler.native_file',
671-
'save_path' => '%kernel.cache_dir%/sessions',
672-
];
673-
674-
return $v;
675-
})
676-
->end()
677643
->children()
678644
->arrayNode('session')
679645
->info('session configuration')
680646
->canBeEnabled()
681647
->children()
682648
->scalarNode('storage_factory_id')->defaultValue('session.storage.factory.native')->end()
683-
->scalarNode('handler_id')->end()
649+
->scalarNode('handler_id')
650+
->info('Defaults to using the native session handler, or to the native *file* session handler if "save_path" is not null.')
651+
->end()
684652
->scalarNode('name')
685653
->validate()
686654
->ifTrue(function ($v) {
@@ -694,14 +662,16 @@ private function addSessionSection(ArrayNodeDefinition $rootNode): void
694662
->scalarNode('cookie_lifetime')->end()
695663
->scalarNode('cookie_path')->end()
696664
->scalarNode('cookie_domain')->end()
697-
->enumNode('cookie_secure')->values([true, false, 'auto'])->end()
665+
->enumNode('cookie_secure')->values([true, false, 'auto'])->defaultValue('auto')->end()
698666
->booleanNode('cookie_httponly')->defaultTrue()->end()
699-
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->end()
667+
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->defaultValue('lax')->end()
700668
->booleanNode('use_cookies')->end()
701669
->scalarNode('gc_divisor')->end()
702670
->scalarNode('gc_probability')->defaultValue(1)->end()
703671
->scalarNode('gc_maxlifetime')->end()
704-
->scalarNode('save_path')->end()
672+
->scalarNode('save_path')
673+
->info('Defaults to "%kernel.cache_dir%/sessions" if the "handler_id" option is not null')
674+
->end()
705675
->integerNode('metadata_update_threshold')
706676
->defaultValue(0)
707677
->info('seconds to wait between 2 session metadata updates')
@@ -1013,25 +983,6 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e
1013983
private function addValidationSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
1014984
{
1015985
$rootNode
1016-
->validate()
1017-
->always(function ($v) {
1018-
if ($v['validation']['enabled'] && !\array_key_exists('email_validation_mode', $v['validation'])) {
1019-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.validation.email_validation_mode" config option is deprecated. It will default to "html5" in 7.0.');
1020-
}
1021-
1022-
if (isset($v['enable_annotations'])) {
1023-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Option "enable_annotations" at "framework.validation" is deprecated. Use the "enable_attributes" option instead.');
1024-
1025-
if (!isset($v['enable_attributes'])) {
1026-
$v['enable_attributes'] = $v['enable_annotations'];
1027-
} else {
1028-
throw new LogicException('The "enable_annotations" and "enable_attributes" options at path "framework.validation" must not be both set. Only the "enable_attributes" option must be used.');
1029-
}
1030-
}
1031-
1032-
return $v;
1033-
})
1034-
->end()
1035986
->children()
1036987
->arrayNode('validation')
1037988
->info('validation configuration')
@@ -1047,7 +998,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
1047998
->validate()->castToArray()->end()
1048999
->end()
10491000
->scalarNode('translation_domain')->defaultValue('validators')->end()
1050-
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->end()
1001+
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->defaultValue('html5')->end()
10511002
->arrayNode('mapping')
10521003
->addDefaultsIfNotSet()
10531004
->fixXmlConfig('path')
@@ -1312,17 +1263,6 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
13121263
private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
13131264
{
13141265
$rootNode
1315-
->validate()
1316-
->always(function (array $v): array {
1317-
if (!\array_key_exists('log', $v['php_errors'])) {
1318-
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.');
1319-
1320-
$v['php_errors']['log'] = $this->debug;
1321-
}
1322-
1323-
return $v;
1324-
})
1325-
->end()
13261266
->children()
13271267
->arrayNode('php_errors')
13281268
->info('PHP errors handling configuration')
@@ -1332,6 +1272,7 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
13321272
->info('Use the application logger instead of the PHP logger for logging PHP errors.')
13331273
->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.')
13341274
->treatNullLike($this->debug)
1275+
->defaultTrue()
13351276
->beforeNormalization()
13361277
->ifArray()
13371278
->then(function (array $v): array {
@@ -2344,23 +2285,6 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
23442285
private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
23452286
{
23462287
$rootNode
2347-
->validate()
2348-
->always(function ($v) {
2349-
if ($v['uid']['enabled']) {
2350-
if (!\array_key_exists('default_uuid_version', $v['uid'])) {
2351-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.uid.default_uuid_version" config option is deprecated. It will default to "7" in 7.0.');
2352-
}
2353-
2354-
if (!\array_key_exists('time_based_uuid_version', $v['uid'])) {
2355-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.uid.time_based_uuid_version" config option is deprecated. It will default to "7" in 7.0.');
2356-
}
2357-
}
2358-
2359-
$v['uid'] += ['default_uuid_version' => 6, 'time_based_uuid_version' => 6];
2360-
2361-
return $v;
2362-
})
2363-
->end()
23642288
->children()
23652289
->arrayNode('uid')
23662290
->info('Uid configuration')
@@ -2369,6 +2293,7 @@ private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIf
23692293
->children()
23702294
->enumNode('default_uuid_version')
23712295
->values([7, 6, 4, 1])
2296+
->defaultValue(7)
23722297
->end()
23732298
->enumNode('name_based_uuid_version')
23742299
->defaultValue(5)
@@ -2379,6 +2304,7 @@ private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIf
23792304
->end()
23802305
->enumNode('time_based_uuid_version')
23812306
->values([7, 6, 1])
2307+
->defaultValue(7)
23822308
->end()
23832309
->scalarNode('time_based_uuid_node')
23842310
->cannotBeEmpty()

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
182182
use Symfony\Component\Validator\ObjectInitializerInterface;
183183
use Symfony\Component\Validator\Validation;
184-
use Symfony\Component\Validator\ValidatorBuilder;
185184
use Symfony\Component\Webhook\Controller\WebhookController;
186185
use Symfony\Component\WebLink\HttpHeaderSerializer;
187186
use Symfony\Component\Workflow;
@@ -1232,10 +1231,15 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
12321231
$container->setParameter('session.storage.options', $options);
12331232

12341233
// session handler (the internal callback registered with PHP session management)
1235-
if (null === $config['handler_id']) {
1234+
if (null === ($config['handler_id'] ?? $config['save_path'] ?? null)) {
12361235
$config['save_path'] = null;
12371236
$container->setAlias('session.handler', 'session.handler.native');
12381237
} else {
1238+
$config['handler_id'] ??= 'session.handler.native_file';
1239+
1240+
if (!\array_key_exists('save_path', $config)) {
1241+
$config['save_path'] = '%kernel.cache_dir%/sessions';
1242+
}
12391243
$container->resolveEnvPlaceholders($config['handler_id'], null, $usedEnvs);
12401244

12411245
if ($usedEnvs || preg_match('#^[a-z]++://#', $config['handler_id'])) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ protected static function getBundleDefaultConfig()
602602
'enabled' => true,
603603
'endpoint' => null,
604604
],
605+
'email_validation_mode' => 'html5',
605606
],
606607
'annotations' => [
607608
'enabled' => false,
@@ -635,11 +636,10 @@ protected static function getBundleDefaultConfig()
635636
'session' => [
636637
'enabled' => false,
637638
'storage_factory_id' => 'session.storage.factory.native',
638-
'handler_id' => 'session.handler.native_file',
639639
'cookie_httponly' => true,
640-
'cookie_samesite' => null,
640+
'cookie_samesite' => 'lax',
641+
'cookie_secure' => 'auto',
641642
'gc_probability' => 1,
642-
'save_path' => '%kernel.cache_dir%/sessions',
643643
'metadata_update_threshold' => 0,
644644
],
645645
'request' => [
@@ -762,9 +762,9 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
762762
],
763763
'uid' => [
764764
'enabled' => !class_exists(FullStack::class) && class_exists(UuidFactory::class),
765-
'default_uuid_version' => 6,
765+
'default_uuid_version' => 7,
766766
'name_based_uuid_version' => 5,
767-
'time_based_uuid_version' => 6,
767+
'time_based_uuid_version' => 7,
768768
],
769769
'html_sanitizer' => [
770770
'enabled' => !class_exists(FullStack::class) && class_exists(HtmlSanitizer::class),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy