-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[HttpFoundation] Add Request::set/getAllowedHttpMethodOverride() to list which HTTP methods can be overridden
#61979
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,7 @@ public function load(array $configs, ContainerBuilder $container): void | |
| $container->parameterCannotBeEmpty('kernel.secret', 'A non-empty value for the parameter "kernel.secret" is required. Did you forget to configure the '.$emptySecretHint.'?'); | ||
|
|
||
| $container->setParameter('kernel.http_method_override', $config['http_method_override']); | ||
| $container->setParameter('kernel.allowed_http_method_override', $config['allowed_http_method_override']); | ||
| $container->setParameter('kernel.trust_x_sendfile_type_header', $config['trust_x_sendfile_type_header']); | ||
| $container->setParameter('kernel.trusted_hosts', [0] === array_keys($config['trusted_hosts']) ? $config['trusted_hosts'][0] : $config['trusted_hosts']); | ||
| $container->setParameter('kernel.default_locale', $config['default_locale']); | ||
|
|
@@ -442,7 +443,7 @@ public function load(array $configs, ContainerBuilder $container): void | |
| } | ||
|
|
||
| $propertyInfoEnabled = $this->readConfigEnabled('property_info', $container, $config['property_info']); | ||
| $this->registerHttpCacheConfiguration($config['http_cache'], $container, $config['http_method_override']); | ||
| $this->registerHttpCacheConfiguration($config['http_cache'], $container, $config['http_method_override'], $config['allowed_http_method_override']); | ||
| $this->registerEsiConfiguration($config['esi'], $container, $loader); | ||
| $this->registerSsiConfiguration($config['ssi'], $container, $loader); | ||
| $this->registerFragmentsConfiguration($config['fragments'], $container, $loader); | ||
|
|
@@ -945,7 +946,7 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont | |
| } | ||
| } | ||
|
|
||
| private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride): void | ||
| private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride, ?array $allowedHttpMethodOverride): void | ||
| { | ||
| $options = $config; | ||
| unset($options['enabled']); | ||
|
|
@@ -968,6 +969,14 @@ private function registerHttpCacheConfiguration(array $config, ContainerBuilder | |
| ->setFactory([Request::class, 'enableHttpMethodParameterOverride']) | ||
| ); | ||
| } | ||
|
|
||
| if (null !== $allowedHttpMethodOverride) { | ||
| $container->getDefinition('http_cache') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For what do we need this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Git blame tells me its for configuring this before httpcache is created, which can happen super early before bundles are initialized
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ->addArgument((new Definition('void')) | ||
| ->setFactory([Request::class, 'setAllowedHttpMethodOverride']) | ||
| ->addArgument($allowedHttpMethodOverride) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| private function registerEsiConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that this naming is quite unfortunate as it's confusing: the setting is only about allowing the use of the
_methodparameter. Overriding using the header is always available.A better name would have been
enable_http_method_override_parameter, like the name of the corresponding static method. In case anyone wants to follow up in another PR (deprecating the option, the parameter, BC/FC layer, etc.).