Skip to content

[FrameworkBundle] deprecate not setting http_method_override #45989

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
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-6.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FrameworkBundle

* Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now.
To prevent services resetting after each message the "--no-reset" option in "messenger:consume" command can be set
* Deprecate not setting the `http_method_override` config option. The default value will change to `false` in 7.0.

HttpKernel
----------
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CHANGELOG
* Add support for first-class callable route controller in `MicroKernelTrait`
* Add tag `routing.condition_service` to autoconfigure routing condition services
* Automatically register kernel methods marked with the `Symfony\Component\Routing\Annotation\Route` attribute or annotation as controllers in `MicroKernelTrait`
* Deprecate not setting the `http_method_override` config option. The default value will change to `false` in 7.0.

6.0
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,23 @@ public function getConfigTreeBuilder(): TreeBuilder
return $v;
})
->end()
->validate()
->always(function ($v) {
if (!isset($v['http_method_override'])) {
trigger_deprecation('symfony/framework-bundle', '6.1', 'Not setting the "framework.http_method_override" config option is deprecated. It will default to "false" in 7.0.');

$v['http_method_override'] = true;
}

return $v;
})
->end()
->fixXmlConfig('enabled_locale')
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
->booleanNode('http_method_override')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only boolean node that wasn't defined as such and missed validation.

->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead")
->defaultTrue()
->treatNullLike(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently setting it to null caused a type error in the FrameworkExtension which is now fixed. making it a boolean node still permits null. so this also ensures that null is transformed to false (instead of true which is the default in boolean node)

->end()
->scalarNode('trust_x_sendfile_type_header')
->info('Set true to enable support for xsendfile in binary file responses.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function getProjectDir(): string

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(static function (ContainerBuilder $container) {
$container->loadFromExtension('framework', [
'http_method_override' => false,
]);
});
}

protected function build(ContainerBuilder $container)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
framework:
http_method_override: false
secret: test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ConfigurationTest extends TestCase
public function testDefaultConfig()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [['secret' => 's3cr3t']]);
$config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t']]);

$this->assertEquals(self::getBundleDefaultConfig(), $config);
}
Expand All @@ -57,7 +57,7 @@ public function testInvalidSessionName($sessionName)
$processor = new Processor();
$processor->processConfiguration(
new Configuration(true),
[['session' => ['name' => $sessionName]]]
[['http_method_override' => false, 'session' => ['name' => $sessionName]]]
);
}

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

$defaultConfig = [
'enabled' => true,
Expand All @@ -103,6 +103,7 @@ public function testValidAssetsPackageNameConfiguration($packageName)
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'assets' => [
'packages' => [
$packageName => [],
Expand Down Expand Up @@ -135,6 +136,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'assets' => $assetConfig,
],
]);
Expand Down Expand Up @@ -184,6 +186,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig)
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'lock' => $lockConfig,
],
]);
Expand Down Expand Up @@ -244,11 +247,13 @@ public function testLockMergeConfigs()
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'lock' => [
'payload' => 'flock',
],
],
[
'http_method_override' => false,
'lock' => [
'payload' => 'semaphore',
],
Expand All @@ -275,6 +280,7 @@ public function testValidSemaphoreConfiguration($semaphoreConfig, $processedConf
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'semaphore' => $semaphoreConfig,
],
]);
Expand Down Expand Up @@ -327,6 +333,7 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau

$processor->processConfiguration($configuration, [
'framework' => [
'http_method_override' => false,
'messenger' => [
'default_bus' => null,
'buses' => [
Expand All @@ -344,6 +351,7 @@ public function testBusMiddlewareDontMerge()
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'messenger' => [
'default_bus' => 'existing_bus',
'buses' => [
Expand All @@ -358,6 +366,7 @@ public function testBusMiddlewareDontMerge()
],
],
[
'http_method_override' => false,
'messenger' => [
'buses' => [
'common_bus' => [
Expand Down Expand Up @@ -406,6 +415,7 @@ public function testItErrorsWhenDefaultBusDoesNotExist()

$processor->processConfiguration($configuration, [
[
'http_method_override' => false,
'messenger' => [
'default_bus' => 'foo',
'buses' => [
Expand All @@ -420,7 +430,7 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
protected static function getBundleDefaultConfig()
{
return [
'http_method_override' => true,
'http_method_override' => false,
'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
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'assets' => [
'version' => 'SomeVersionScheme',
'base_urls' => 'http://cdn.example.com',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'assets' => [
'enabled' => false,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'assets' => [
'version_strategy' => 'assets.custom_version_strategy',
'base_urls' => 'http://cdn.example.com',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'cache' => [
'pools' => [
'cache.foo' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'cache' => [
'app' => 'cache.adapter.redis_tag_aware',
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'cache' => [
'app' => 'cache.redis_tag_aware.foo',
'pools' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'csrf_protection' => true,
'session' => [
'storage_factory_id' => 'session.storage.factory.native',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'csrf_protection' => [
'enabled' => true,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

$container->loadFromExtension('framework', []);
$container->loadFromExtension('framework', [
'http_method_override' => false,]);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'fragments' => [
'enabled' => false,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'esi' => [
'enabled' => false,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

$container->loadFromExtension('framework', [
'http_method_override' => false,
'exceptions' => [
BadRequestHttpException::class => [
'log_level' => 'info',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'form' => [
'legacy_error_messages' => false,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'form' => [
'csrf_protection' => [
'enabled' => false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'fragments' => [
'enabled' => true,
'hinclude_default_template' => 'global_hinclude_template',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'html_sanitizer' => [
'default' => 'my.sanitizer',
'sanitizers' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'max_host_connections' => 4,
'default_options' => null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'default_options' => [
'headers' => ['X-powered' => 'PHP'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'default_options' => null,
'mock_response_factory' => 'my_response_factory',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'max_host_connections' => 4,
'default_options' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'default_options' => [
'retry_failed' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'scoped_clients' => [
'foo' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'http_client' => [
'default_options' => [
'resolve' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'secret' => 's3cr3t',
'default_locale' => 'fr',
'router' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'mailer' => [
'dsn' => 'smtp://example.com',
'envelope' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'mailer' => [
'dsn' => 'smtp://example.com',
'message_bus' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

return static function (ContainerConfigurator $container) {
$container->extension('framework', [
'http_method_override' => false,
'mailer' => [
'dsn' => 'smtp://example.com',
'envelope' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$container->loadFromExtension('framework', [
'http_method_override' => false,
'mailer' => [
'dsn' => 'smtp://example.com',
'message_bus' => 'app.another_bus',
Expand Down
Loading