10000 [FrameworkBundle] Deprecate not setting some options (uid, validation) by Jean-Beru · Pull Request #51357 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Deprecate not setting some options (uid, validation) #51357

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
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions UPGRADE-6.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ FrameworkBundle
* [BC break] Add native return type to `Translator` and to `Application::reset()`
* Deprecate the integration of Doctrine annotations, either uninstall the `doctrine/annotations` package or disable
the integration by setting `framework.annotations` to `false`
* Deprecate not setting the `framework.handle_all_throwables` config option; it will default to `true` in 7.0
* Deprecate not setting the `framework.php_errors.log` config option; it will default to `true` in 7.0
* Deprecate not setting the `framework.session.cookie_secure` config option; it will default to `auto` in 7.0
* Deprecate not setting the `framework.session.cookie_samesite` config option; it will default to `lax` in 7.0
* 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
* Deprecate not setting the `framework.uid.default_uuid_version` config option; it will default to `7` in 7.0
* Deprecate not setting the `framework.uid.time_based_uuid_version` config option; it will default to `7` in 7.0
* Deprecate not setting the `framework.validation.email_validation_mode` config option; it will default to `html5` in 7.0

HttpFoundation
--------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected function configureContainer(ContainerConfigurator $container): void
'test' => true,
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
]);

$container->services()
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ CHANGELOG
* Add `DomCrawlerAssertionsTrait::assertAnySelectorTextNotContains(string $selector, string $text)`
* Deprecate `EnableLoggerDebugModePass`, use argument `$debug` of HttpKernel's `Logger` instead
* Deprecate `AddDebugLogProcessorPass::configureLogger()`, use HttpKernel's `DebugLoggerConfigurator` instead
* Deprecate not setting the `framework.handle_all_throwables` config option; it will default to `true` in 7.0
* Deprecate not setting the `framework.php_errors.log` config option; it will default to `true` in 7.0
* Deprecate not setting the `framework.session.cookie_secure` config option; it will default to `auto` in 7.0
* Deprecate not setting the `framework.session.cookie_samesite` config option; it will default to `lax` in 7.0
* 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
* Deprecate not setting the `framework.uid.default_uuid_version` config option; it will default to `7` in 7.0
* Deprecate not setting the `framework.uid.time_based_uuid_version` config option; it will default to `7` in 7.0
* Deprecate not setting the `framework.validation.email_validation_mode` config option; it will default to `html5` in 7.0

6.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public function getConfigTreeBuilder(): TreeBuilder

$v['http_method_override'] = true;
}
if (!isset($v['handle_all_throwables'])) {
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.');
}

return $v;
})
Expand Down Expand Up @@ -655,13 +658,34 @@ private function addRouterSection(ArrayNodeDefinition $rootNode): void
private function addSessionSection(ArrayNodeDefinition $rootNode): void
{
$rootNode
->validate()
->always(function (array $v): array {
if ($v['session']['enabled']) {
if (!\array_key_exists('cookie_secure', $v['session'])) {
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.');
}

if (!\array_key_exists('cookie_samesite', $v['session'])) {
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.');
}

if (!\array_key_exists('handler_id', $v['session'])) {
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.');
}
}

$v['session'] += ['cookie_samesite' => null, 'handler_id' => 'session.handler.native_file'];

return $v;
})
->end()
->children()
->arrayNode('session')
->info('session configuration')
->canBeEnabled()
->children()
->scalarNode('storage_factory_id')->defaultValue('session.storage.factory.native')->end()
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
->scalarNode('handler_id')->end()
->scalarNode('name')
->validate()
->ifTrue(function ($v) {
Expand All @@ -677,7 +701,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode): void
->scalarNode('cookie_domain')->end()
->enumNode('cookie_secure')->values([true, false, 'auto'])->end()
->booleanNode('cookie_httponly')->defaultTrue()->end()
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->defaultNull()->end()
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT, Cookie::SAMESITE_NONE])->end()
->booleanNode('use_cookies')->end()
->scalarNode('gc_divisor')->end()
->scalarNode('gc_probability')->defaultValue(1)->end()
Expand Down Expand Up @@ -994,6 +1018,15 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e
private function addValidationSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
{
$rootNode
->validate()
->always(function ($v) {
if ($v['validation']['enabled'] && !\array_key_exists('email_validation_mode', $v['validation'])) {
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.');
}

return $v;
})
->end()
->children()
->arrayNode('validation')
->info('validation configuration')
Expand Down Expand Up @@ -1264,6 +1297,17 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
{
$rootNode
->validate()
->always(function (array $v): array {
if (!\array_key_exists('log', $v['php_errors'])) {
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.');

$v['php_errors']['log'] = $this->debug;
}

return $v;
})
->end()
->children()
->arrayNode('php_errors')
->info('PHP errors handling configuration')
Expand All @@ -1272,7 +1316,6 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode): void
->variableNode('log')
->info('Use the application logger instead of the PHP logger for logging PHP errors.')
->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.')
->defaultValue($this->debug)
->treatNullLike($this->debug)
->beforeNormalization()
->ifArray()
Expand Down Expand Up @@ -2316,14 +2359,30 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
{
$rootNode
->validate()
->always(function ($v) {
if ($v['uid']['enabled']) {
if (!\array_key_exists('default_uuid_version', $v['uid'])) {
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.');
}

if (!\array_key_exists('time_based_uuid_version', $v['uid'])) {
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.');
}
}

$v['uid'] += ['default_uuid_version' => 6, 'time_based_uuid_version' => 6];

return $v;
})
->end()
->children()
->arrayNode('uid')
->info('Uid configuration')
->{$enableIfStandalone('symfony/uid', UuidFactory::class)}()
->addDefaultsIfNotSet()
->children()
->enumNode('default_uuid_version')
->defaultValue(6)
->values([7, 6, 4, 1])
->end()
->enumNode('name_based_uuid_version')
Expand All @@ -2334,7 +2393,6 @@ private function addUidSection(ArrayNodeDefinition $rootNode, callable $enableIf
->cannotBeEmpty()
->end()
->enumNode('time_based_uuid_version')
->defaultValue(6)
->values([7, 6, 1])
->end()
->scalarNode('time_based_uuid_node')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
]);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
framework:
annotations: false
http_method_override: false
handle_all_throwables: true
php_errors:
log: true
secret: test
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ class ConfigurationTest extends TestCase
public function testDefaultConfig()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t', 'serializer' => ['default_context' => ['foo' => 'bar']]]]);
$config = $processor->processConfiguration(new Configuration(true), [[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'secret' => 's3cr3t',
'serializer' => ['default_context' => ['foo' => 'bar']],
]]);

$this->assertEquals(self::getBundleDefaultConfig(), $config);
}
Expand All @@ -59,7 +65,12 @@ public function testInvalidSessionName($sessionName)
$processor = new Processor();
$processor->processConfiguration(
new Configuration(true),
[['http_method_override' => false, 'session' => ['name' => $sessionName]]]
[[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'session' => ['name' => $sessionName, 'cookie_secure' => 'auto', 'cookie_samesite' => 'lax'],
]]
);
}

Expand All @@ -79,7 +90,12 @@ public function testAssetsCanBeEnabled()
{
$processor = new Processor();
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [['http_method_override' => false, 'assets' => null]]);
$config = $processor->processConfiguration($configuration, [[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => null,
]]);

$defaultConfig = [
'enabled' => true,
Expand All @@ -100,7 +116,12 @@ public function testAssetMapperCanBeEnabled()
{
$processor = new Processor();
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [['http_method_override' => false, 'asset_mapper' => null]]);
$config = $processor->processConfiguration($configuration, [[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'asset_mapper' => null,
]]);

$defaultConfig = [
'enabled' => true,
Expand Down Expand Up @@ -130,6 +151,8 @@ public function testValidAssetsPackageNameConfiguration($packageName)
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => [
'packages' => [
$packageName => [],
Expand Down Expand Up @@ -163,6 +186,8 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess
$processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => $assetConfig,
],
]);
Expand Down Expand Up @@ -211,6 +236,8 @@ public function testValidLockConfiguration($lockConfig, $processedConfig)
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => $lockConfig,
],
]);
Expand Down Expand Up @@ -272,12 +299,16 @@ public function testLockMergeConfigs()
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => [
'payload' => 'flock',
],
],
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => [
'payload' => 'semaphore',
],
Expand Down Expand Up @@ -305,6 +336,8 @@ public function testValidSemaphoreConfiguration($semaphoreConfig, $processedConf
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'semaphore' => $semaphoreConfig,
],
]);
Expand Down Expand Up @@ -358,6 +391,8 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau
$processor->processConfiguration($configuration, [
'framework' => [
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'messenger' => [
'default_bus' => null,
'buses' => [
Expand All @@ -376,6 +411,8 @@ public function testBusMiddlewareDontMerge()
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'messenger' => [
'default_bus' => 'existing_bus',
'buses' => [
Expand All @@ -391,6 +428,8 @@ public function testBusMiddlewareDontMerge()
],
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'messenger' => [
'buses' => [
'common_bus' => [
Expand Down Expand Up @@ -440,6 +479,8 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
$processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'messenger' => [
'default_bus' => 'foo',
'buses' => [
Expand All @@ -459,6 +500,8 @@ public function testLockCanBeDisabled()
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => ['enabled' => false],
],
]);
Expand All @@ -477,6 +520,8 @@ public function testEnabledLockNeedsResources()
$processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => ['enabled' => true],
],
]);
Expand All @@ -486,6 +531,7 @@ protected static function getBundleDefaultConfig()
{
return [
'http_method_override' => false,
'handle_all_throwables' => true,
'trust_x_sendfile_type_header' => false,
'ide' => '%env(default::SYMFONY_IDE)%',
'default_locale' => 'en',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => [
'version' => 'SomeVersionScheme',
'base_urls' => 'http://cdn.example.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => [
'enabled' => false,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'assets' => [
'version_strategy' => 'assets.custom_version_strategy',
'base_urls' => 'http://cdn.example.com',
Expand Down
Loading
0