From 1fc2a04e0048220a556c2ce76e665bff1506acf7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 22 Mar 2021 00:25:00 +0100 Subject: [PATCH] Rename master request to main request --- UPGRADE-5.3.md | 4 + UPGRADE-6.0.md | 3 + .../Monolog/Handler/ChromePhpHandler.php | 2 +- .../HttpCodeActivationStrategy.php | 2 +- .../NotFoundActivationStrategy.php | 2 +- .../Bridge/Monolog/Handler/FirePHPHandler.php | 2 +- .../Monolog/Processor/RouteProcessor.php | 2 +- .../Bridge/Monolog/Processor/WebProcessor.php | 2 +- .../Tests/Processor/RouteProcessorTest.php | 4 +- .../Tests/Processor/WebProcessorTest.php | 2 +- src/Symfony/Bridge/Monolog/composer.json | 4 +- .../Twig/Extension/WebLinkExtension.php | 2 +- src/Symfony/Bridge/Twig/composer.json | 4 +- .../Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../DependencyInjection/Configuration.php | 3 +- .../FrameworkExtension.php | 2 +- .../FrameworkBundle/HttpCache/HttpCache.php | 2 +- .../Resources/config/profiling.php | 2 +- .../Resources/config/schema/symfony-1.0.xsd | 1 + .../DependencyInjection/ConfigurationTest.php | 1 + .../Tests/Kernel/MicroKernelTraitTest.php | 4 +- .../Bundle/FrameworkBundle/composer.json | 2 +- .../EventListener/FirewallListener.php | 4 +- .../Security/UserAuthenticator.php | 2 +- .../SecurityDataCollectorTest.php | 2 +- .../Debug/TraceableFirewallListenerTest.php | 2 +- .../Bundle/SecurityBundle/composer.json | 3 +- .../EventListener/WebDebugToolbarListener.php | 2 +- .../WebDebugToolbarListenerTest.php | 30 ++--- .../Bundle/WebProfilerBundle/composer.json | 2 +- .../Asset/Context/RequestStackContext.php | 4 +- .../Tests/Context/RequestStackContextTest.php | 4 +- src/Symfony/Component/Asset/composer.json | 5 +- .../Component/HttpFoundation/CHANGELOG.md | 3 +- .../Component/HttpFoundation/RequestStack.php | 24 +++- .../HttpFoundation/Session/SessionFactory.php | 2 +- .../HttpFoundation/Tests/RequestStackTest.php | 27 +++- .../Component/HttpFoundation/UrlHelper.php | 4 +- src/Symfony/Component/HttpKernel/CHANGELOG.md | 2 + .../DataCollector/DumpDataCollector.php | 2 +- .../DataCollector/EventDataCollector.php | 2 +- .../DataCollector/LoggerDataCollector.php | 2 +- .../DataCollector/RequestDataCollector.php | 4 +- .../HttpKernel/Debug/FileLinkFormatter.php | 2 +- .../HttpKernel/Event/KernelEvent.php | 18 ++- .../HttpKernel/Event/TerminateEvent.php | 6 +- .../EventListener/AbstractSessionListener.php | 6 +- .../AbstractTestSessionListener.php | 6 +- .../EventListener/DebugHandlersListener.php | 2 +- .../EventListener/FragmentListener.php | 2 +- .../EventListener/ProfilerListener.php | 15 +-- .../EventListener/ResponseListener.php | 2 +- .../EventListener/SessionListener.php | 8 +- .../StreamedResponseListener.php | 2 +- .../EventListener/SurrogateListener.php | 2 +- .../EventListener/ValidateRequestListener.php | 2 +- .../HttpKernel/Fragment/FragmentHandler.php | 2 +- .../HttpKernel/HttpCache/HttpCache.php | 14 +- .../HttpCache/ResponseCacheStrategy.php | 2 +- .../Component/HttpKernel/HttpClientKernel.php | 2 +- .../Component/HttpKernel/HttpKernel.php | 8 +- .../HttpKernel/HttpKernelBrowser.php | 2 +- .../HttpKernel/HttpKernelInterface.php | 12 +- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- .../DataCollector/LoggerDataCollectorTest.php | 12 +- .../RequestDataCollectorTest.php | 4 +- .../DebugHandlersListenerTest.php | 2 +- .../DisallowRobotsIndexingListenerTest.php | 2 +- .../Tests/EventListener/ErrorListenerTest.php | 16 +-- .../EventListener/FragmentListenerTest.php | 2 +- .../EventListener/LocaleAwareListenerTest.php | 4 +- .../EventListener/LocaleListenerTest.php | 4 +- .../EventListener/ProfilerListenerTest.php | 12 +- .../EventListener/ResponseListenerTest.php | 6 +- .../EventListener/RouterListenerTest.php | 14 +- .../EventListener/SessionListenerTest.php | 52 ++++---- .../EventListener/SurrogateListenerTest.php | 4 +- .../EventListener/TestSessionListenerTest.php | 18 +-- .../ValidateRequestListenerTest.php | 4 +- .../Tests/HttpCache/HttpCacheTest.php | 8 +- .../Tests/HttpCache/HttpCacheTestCase.php | 2 +- .../HttpCache/ResponseCacheStrategyTest.php | 120 +++++++++--------- .../Tests/HttpCache/SubRequestHandlerTest.php | 10 +- .../Tests/HttpCache/TestHttpKernel.php | 2 +- .../HttpCache/TestMultipleHttpKernel.php | 2 +- .../HttpKernel/Tests/HttpKernelTest.php | 14 +- .../Component/HttpKernel/Tests/KernelTest.php | 6 +- .../Component/HttpKernel/composer.json | 2 +- .../Security/Csrf/CsrfTokenManager.php | 4 +- .../Security/Http/Event/LazyResponseEvent.php | 11 +- .../EventListener/LoginThrottlingListener.php | 2 +- .../Component/Security/Http/Firewall.php | 2 +- .../Http/Firewall/ContextListener.php | 4 +- .../Http/RememberMe/ResponseListener.php | 2 +- .../Tests/Firewall/AccessListenerTest.php | 18 +-- .../AnonymousAuthenticationListenerTest.php | 6 +- .../Tests/Firewall/ContextListenerTest.php | 18 +-- .../Tests/Firewall/ExceptionListenerTest.php | 2 +- .../Tests/Firewall/RememberMeListenerTest.php | 2 +- .../Tests/Firewall/SwitchUserListenerTest.php | 2 +- ...PasswordFormAuthenticationListenerTest.php | 10 +- ...PasswordJsonAuthenticationListenerTest.php | 32 ++--- .../Security/Http/Tests/FirewallTest.php | 4 +- .../Tests/RememberMe/ResponseListenerTest.php | 2 +- .../Component/Security/Http/composer.json | 2 +- .../EventListener/AddLinkHeaderListener.php | 2 +- .../AddLinkHeaderListenerTest.php | 2 +- src/Symfony/Component/WebLink/composer.json | 4 +- 108 files changed, 416 insertions(+), 339 deletions(-) diff --git a/UPGRADE-5.3.md b/UPGRADE-5.3.md index 06dc3f5782..6c9f656e56 100644 --- a/UPGRADE-5.3.md +++ b/UPGRADE-5.3.md @@ -36,11 +36,13 @@ FrameworkBundle * Deprecate the `framework.session.storage_id` configuration option, use the `framework.session.storage_factory_id` configuration option instead * Deprecate the `session` service and the `SessionInterface` alias, use the `\Symfony\Component\HttpFoundation\Request::getSession()` or the new `\Symfony\Component\HttpFoundation\RequestStack::getSession()` methods instead * Deprecate the `KernelTestCase::$container` property, use `KernelTestCase::getContainer()` instead + * Rename the container parameter `profiler_listener.only_master_requests` to `profiler_listener.only_main_requests` HttpFoundation -------------- * Deprecate the `NamespacedAttributeBag` class + * Deprecate the `RequestStack::getMasterRequest()` method and add `getMainRequest()` as replacement HttpKernel ---------- @@ -49,6 +51,8 @@ HttpKernel * Deprecate `ArgumentMetadata::getAttribute()`, use `getAttributes()` instead * Mark the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal * Deprecate returning a `ContainerBuilder` from `KernelInterface::registerContainerConfiguration()` + * Deprecate `HttpKernelInterface::MASTER_REQUEST` and add `HttpKernelInterface::MAIN_REQUEST` as replacement + * Deprecate `KernelEvent::isMasterRequest()` and add `isMainRequest()` as replacement Messenger --------- diff --git a/UPGRADE-6.0.md b/UPGRADE-6.0.md index 2ab9f4c96c..997029ae61 100644 --- a/UPGRADE-6.0.md +++ b/UPGRADE-6.0.md @@ -89,6 +89,7 @@ HttpFoundation `BinaryFileResponse::create()` methods (use `__construct()` instead) * Not passing a `Closure` together with `FILTER_CALLBACK` to `ParameterBag::filter()` throws an `InvalidArgumentException`; wrap your filter in a closure instead. * Removed the `Request::HEADER_X_FORWARDED_ALL` constant, use either `Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO` or `Request::HEADER_X_FORWARDED_AWS_ELB` or `Request::HEADER_X_FORWARDED_TRAEFIK`constants instead. + * Rename `RequestStack::getMasterRequest()` to `getMainRequest()` HttpKernel ---------- @@ -98,6 +99,8 @@ HttpKernel * Make `WarmableInterface::warmUp()` return a list of classes or files to preload on PHP 7.4+ * Remove support for `service:action` syntax to reference controllers. Use `serviceOrFqcn::method` instead. * Remove support for returning a `ContainerBuilder` from `KernelInterface::registerContainerConfiguration()` + * Rename `HttpKernelInterface::MASTER_REQUEST` to `MAIN_REQUEST` + * Rename `KernelEvent::isMasterRequest()` to `isMainRequest()` Inflector --------- diff --git a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php index e7049c4b61..16c082f11b 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php @@ -36,7 +36,7 @@ class ChromePhpHandler extends BaseChromePhpHandler */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php index e87b8677ce..92dbbcbd12 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php +++ b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php @@ -65,7 +65,7 @@ class HttpCodeActivationStrategy extends ErrorLevelActivationStrategy implements $isActivated && isset($record['context']['exception']) && $record['context']['exception'] instanceof HttpException - && ($request = $this->requestStack->getMasterRequest()) + && ($request = $this->requestStack->getMainRequest()) ) { foreach ($this->exclusions as $exclusion) { if ($record['context']['exception']->getStatusCode() !== $exclusion['code']) { diff --git a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php index a9806d7e92..4ab21f9df3 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php +++ b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php @@ -57,7 +57,7 @@ class NotFoundActivationStrategy extends ErrorLevelActivationStrategy implements && isset($record['context']['exception']) && $record['context']['exception'] instanceof HttpException && 404 == $record['context']['exception']->getStatusCode() - && ($request = $this->requestStack->getMasterRequest()) + && ($request = $this->requestStack->getMainRequest()) ) { return !preg_match($this->exclude, $request->getPathInfo()); } diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index 0a9a6965db..b5906b18c2 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -36,7 +36,7 @@ class FirePHPHandler extends BaseFirePHPHandler */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php index 23b95d9b85..26c278ed0e 100644 --- a/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/RouteProcessor.php @@ -51,7 +51,7 @@ class RouteProcessor implements EventSubscriberInterface, ResetInterface public function addRouteData(RequestEvent $event) { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->reset(); } diff --git a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php index 98ec10ca6d..f72023cdfd 100644 --- a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php @@ -33,7 +33,7 @@ class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface public function onKernelRequest(RequestEvent $event) { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->serverData = $event->getRequest()->server->all(); $this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp(); } diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php index 06336f1a59..6e6afa92c4 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/RouteProcessorTest.php @@ -123,14 +123,14 @@ class RouteProcessorTest extends TestCase $this->assertEquals(['extra' => []], $record); } - private function getRequestEvent(Request $request, int $requestType = HttpKernelInterface::MASTER_REQUEST): RequestEvent + private function getRequestEvent(Request $request, int $requestType = HttpKernelInterface::MAIN_REQUEST): RequestEvent { return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, $requestType); } private function getFinishRequestEvent(Request $request): FinishRequestEvent { - return new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + return new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); } private function mockEmptyRequest(): Request diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 905e6efb61..9b70b4bbfb 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -89,7 +89,7 @@ class WebProcessorTest extends TestCase $request->server->replace($server); $request->headers->replace($server); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); return [$event, $server]; } diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index ee48ea0330..1eee4ac2d2 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "monolog/monolog": "^1.25.1|^2", "symfony/service-contracts": "^1.1|^2", - "symfony/http-kernel": "^4.4|^5.0", + "symfony/http-kernel": "^5.3", "symfony/deprecation-contracts": "^2.1" }, "require-dev": { @@ -32,7 +32,7 @@ }, "conflict": { "symfony/console": "<4.4", - "symfony/http-foundation": "<4.4" + "symfony/http-foundation": "<5.3" }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", diff --git a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php index 4b8217d932..652a75762c 100644 --- a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php @@ -56,7 +56,7 @@ final class WebLinkExtension extends AbstractExtension */ public function link(string $uri, string $rel, array $attributes = []): string { - if (!$request = $this->requestStack->getMasterRequest()) { + if (!$request = $this->requestStack->getMainRequest()) { return $uri; } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index c13e2f51c0..f4e70b0906 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -29,7 +29,7 @@ "symfony/dependency-injection": "^4.4|^5.0", "symfony/finder": "^4.4|^5.0", "symfony/form": "^5.3", - "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-foundation": "^5.3", "symfony/http-kernel": "^4.4|^5.0", "symfony/intl": "^4.4|^5.0", "symfony/mime": "^5.2", @@ -57,7 +57,7 @@ "phpdocumentor/type-resolver": "<1.4.0", "symfony/console": "<4.4", "symfony/form": "<5.3", - "symfony/http-foundation": "<4.4", + "symfony/http-foundation": "<5.3", "symfony/http-kernel": "<4.4", "symfony/translation": "<5.2", "symfony/workflow": "<5.2" diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 406ee6058f..17f36c33c8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -17,6 +17,7 @@ CHANGELOG * Add support to use a PSR-6 compatible cache for Doctrine annotations * Deprecate all other values than "none", "php_array" and "file" for `framework.annotation.cache` * Add `KernelTestCase::getContainer()` as the best way to get a container in tests + * Rename the container parameter `profiler_listener.only_master_requests` to `profiler_listener.only_main_requests` 5.2.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 0fdb34cbb6..a7421573e0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -304,7 +304,8 @@ class Configuration implements ConfigurationInterface ->children() ->booleanNode('collect')->defaultTrue()->end() ->booleanNode('only_exceptions')->defaultFalse()->end() - ->booleanNode('only_master_requests')->defaultFalse()->end() + ->booleanNode('only_main_requests')->defaultFalse()->end() + ->booleanNode('only_master_requests')->setDeprecated('symfony/framework-bundle', '5.3', 'Option "%node%" at "%path%" is deprecated, use "only_main_requests" instead.')->defaultFalse()->end() ->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 80f573235b..5f623d894c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -711,7 +711,7 @@ class FrameworkExtension extends Extension } $container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']); - $container->setParameter('profiler_listener.only_master_requests', $config['only_master_requests']); + $container->setParameter('profiler_listener.only_main_requests', $config['only_main_requests'] || $config['only_master_requests']); // Choose storage class based on the DSN [$class] = explode(':', $config['dsn'], 2); diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index 45b2ca7856..768ccf6733 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -63,7 +63,7 @@ class HttpCache extends BaseHttpCache parent::__construct($kernel, $this->createStore(), $this->createSurrogate(), array_merge($this->options, $this->getOptions())); } - public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true) + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true) { if ($this->kernel->getContainer()->getParameter('kernel.http_method_override')) { Request::enableHttpMethodParameterOverride(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php index 68a09c9f5f..c022158339 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php @@ -31,7 +31,7 @@ return static function (ContainerConfigurator $container) { service('request_stack'), null, param('profiler_listener.only_exceptions'), - param('profiler_listener.only_master_requests'), + param('profiler_listener.only_main_requests'), ]) ->tag('kernel.event_subscriber') ; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 592849641b..1027c3c6f9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -87,6 +87,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 1430ee9851..efa0acf856 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -397,6 +397,7 @@ class ConfigurationTest extends TestCase 'enabled' => false, 'only_exceptions' => false, 'only_master_requests' => false, + 'only_main_requests' => false, 'dsn' => 'file:%kernel.cache_dir%/profiler', 'collect' => true, ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index cc5573d43d..d905a3f6a5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -122,7 +122,7 @@ class MicroKernelTraitTest extends TestCase }; $request = Request::create('/'); - $response = $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false); + $response = $kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, false); $this->assertSame('Hello World!', $response->getContent()); } @@ -156,7 +156,7 @@ class MicroKernelTraitTest extends TestCase $this->expectExceptionMessage('"Symfony\Bundle\FrameworkBundle\Tests\Kernel\MinimalKernel@anonymous" uses "Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".'); $request = Request::create('/'); - $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false); + $kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, false); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 68167b944a..18a7196181 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -25,7 +25,7 @@ "symfony/event-dispatcher": "^5.1", "symfony/error-handler": "^4.4.1|^5.0.1", "symfony/http-foundation": "^5.3", - "symfony/http-kernel": "^5.2.1", + "symfony/http-kernel": "^5.3", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php80": "^1.15", "symfony/filesystem": "^4.4|^5.0", diff --git a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php index 778bfcfeff..ca3931a3bf 100644 --- a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php +++ b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php @@ -38,7 +38,7 @@ class FirewallListener extends Firewall public function configureLogoutUrlGenerator(RequestEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } @@ -49,7 +49,7 @@ class FirewallListener extends Firewall public function onKernelFinishRequest(FinishRequestEvent $event) { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->logoutUrlGenerator->setCurrentFirewall(null); } diff --git a/src/Symfony/Bundle/SecurityBundle/Security/UserAuthenticator.php b/src/Symfony/Bundle/SecurityBundle/Security/UserAuthenticator.php index 70ac67a865..72f9fd4772 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/UserAuthenticator.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/UserAuthenticator.php @@ -49,7 +49,7 @@ class UserAuthenticator implements UserAuthenticatorInterface private function getUserAuthenticator(): UserAuthenticatorInterface { - $firewallConfig = $this->firewallMap->getFirewallConfig($this->requestStack->getMasterRequest()); + $firewallConfig = $this->firewallMap->getFirewallConfig($this->requestStack->getMainRequest()); if (null === $firewallConfig) { throw new LogicException('Cannot call authenticate on this request, as it is not behind a firewall.'); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 1febc6ad5e..428564020d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -188,7 +188,7 @@ class SecurityDataCollectorTest extends TestCase public function testGetListeners() { $request = new Request(); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $event->setResponse($response = new Response()); $listener = function ($e) use ($event, &$listenerCalled) { $listenerCalled += $e === $event; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php index c1be247e81..2e69efd08d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php @@ -29,7 +29,7 @@ class TraceableFirewallListenerTest extends TestCase public function testOnKernelRequestRecordsListeners() { $request = new Request(); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $event->setResponse($response = new Response()); $listener = function ($e) use ($event, &$listenerCalled) { $listenerCalled += $e === $event; diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 05688dd016..46873c4237 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -22,7 +22,8 @@ "symfony/dependency-injection": "^5.3", "symfony/deprecation-contracts": "^2.1", "symfony/event-dispatcher": "^5.1", - "symfony/http-kernel": "^5.0", + "symfony/http-kernel": "^5.3", + "symfony/http-foundation": "^5.3", "symfony/password-hasher": "^5.3", "symfony/polyfill-php80": "^1.15", "symfony/security-core": "^5.3", diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index 8c1ef6177d..da5397c233 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -88,7 +88,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface } } - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 4e84567fa5..15185e2898 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -67,7 +67,7 @@ class WebDebugToolbarListenerTest extends TestCase { $response = new Response('Some content', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -80,7 +80,7 @@ class WebDebugToolbarListenerTest extends TestCase { $response = new Response('Some content', '301'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true); $listener->onKernelResponse($event); @@ -94,7 +94,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -110,7 +110,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Type', 'text/xml'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -126,7 +126,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $response->headers->set('Content-Disposition', 'attachment; filename=test.html'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -142,7 +142,7 @@ class WebDebugToolbarListenerTest extends TestCase { $response = new Response('', $statusCode); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -167,7 +167,7 @@ class WebDebugToolbarListenerTest extends TestCase { $response = new Response(''); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -199,7 +199,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response('
Some content
'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -215,7 +215,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -231,7 +231,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock()); $listener->onKernelResponse($event); @@ -252,7 +252,7 @@ class WebDebugToolbarListenerTest extends TestCase ->willReturn('http://mydomain.com/_profiler/xxxxxxxx') ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -273,7 +273,7 @@ class WebDebugToolbarListenerTest extends TestCase ->willThrowException(new \Exception('foo')) ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -294,7 +294,7 @@ class WebDebugToolbarListenerTest extends TestCase ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")) ; - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator); $listener->onKernelResponse($event); @@ -307,7 +307,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $cspHandler = $this->createMock(ContentSecurityPolicyHandler::class); $cspHandler->expects($this->once()) @@ -328,7 +328,7 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response(''); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); - $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response); $cspHandler = $this->createMock(ContentSecurityPolicyHandler::class); $cspHandler->expects($this->never()) diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 277f8095c0..83b29f9774 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "symfony/config": "^4.4|^5.0", "symfony/framework-bundle": "^5.3", - "symfony/http-kernel": "^5.2", + "symfony/http-kernel": "^5.3", "symfony/routing": "^4.4|^5.0", "symfony/twig-bundle": "^4.4|^5.0", "twig/twig": "^2.13|^3.0.4" diff --git a/src/Symfony/Component/Asset/Context/RequestStackContext.php b/src/Symfony/Component/Asset/Context/RequestStackContext.php index b63f4663fc..3227a22f8b 100644 --- a/src/Symfony/Component/Asset/Context/RequestStackContext.php +++ b/src/Symfony/Component/Asset/Context/RequestStackContext.php @@ -36,7 +36,7 @@ class RequestStackContext implements ContextInterface */ public function getBasePath() { - if (!$request = $this->requestStack->getMasterRequest()) { + if (!$request = $this->requestStack->getMainRequest()) { return $this->basePath; } @@ -48,7 +48,7 @@ class RequestStackContext implements ContextInterface */ public function isSecure() { - if (!$request = $this->requestStack->getMasterRequest()) { + if (!$request = $this->requestStack->getMainRequest()) { return $this->secure; } diff --git a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php index ed323749af..4ac421b13c 100644 --- a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php +++ b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php @@ -34,7 +34,7 @@ class RequestStackContextTest extends TestCase $request->method('getBasePath') ->willReturn($testBasePath); $requestStack = $this->createMock(RequestStack::class); - $requestStack->method('getMasterRequest') + $requestStack->method('getMainRequest') ->willReturn($request); $requestStackContext = new RequestStackContext($requestStack); @@ -56,7 +56,7 @@ class RequestStackContextTest extends TestCase $request->method('isSecure') ->willReturn(true); $requestStack = $this->createMock(RequestStack::class); - $requestStack->method('getMasterRequest') + $requestStack->method('getMainRequest') ->willReturn($request); $requestStackContext = new RequestStackContext($requestStack); diff --git a/src/Symfony/Component/Asset/composer.json b/src/Symfony/Component/Asset/composer.json index 20487e99c8..ff6b93d720 100644 --- a/src/Symfony/Component/Asset/composer.json +++ b/src/Symfony/Component/Asset/composer.json @@ -24,9 +24,12 @@ }, "require-dev": { "symfony/http-client": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-foundation": "^5.3", "symfony/http-kernel": "^4.4|^5.0" }, + "conflict": { + "symfony/http-foundation": "<5.3" + }, "autoload": { "psr-4": { "Symfony\\Component\\Asset\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/HttpFoundation/CHANGELOG.md b/src/Symfony/Component/HttpFoundation/CHANGELOG.md index d6a57aae14..969a96dd52 100644 --- a/src/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/src/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -8,7 +8,8 @@ CHANGELOG * Calling `Request::getSession()` when there is no available session throws a `SessionNotFoundException` * Add the `RequestStack::getSession` method * Deprecate the `NamespacedAttributeBag` class - * added `ResponseFormatSame` PHPUnit constraint + * Add `ResponseFormatSame` PHPUnit constraint + * Deprecate the `RequestStack::getMasterRequest()` method and add `getMainRequest()` as replacement 5.2.0 ----- diff --git a/src/Symfony/Component/HttpFoundation/RequestStack.php b/src/Symfony/Component/HttpFoundation/RequestStack.php index fe07d594b1..d4d2d5fa01 100644 --- a/src/Symfony/Component/HttpFoundation/RequestStack.php +++ b/src/Symfony/Component/HttpFoundation/RequestStack.php @@ -65,15 +65,13 @@ class RequestStack } /** - * Gets the master Request. + * Gets the main request. * - * Be warned that making your code aware of the master request + * Be warned that making your code aware of the main request * might make it un-compatible with other features of your framework * like ESI support. - * - * @return Request|null */ - public function getMasterRequest() + public function getMainRequest(): ?Request { if (!$this->requests) { return null; @@ -82,6 +80,20 @@ class RequestStack return $this->requests[0]; } + /** + * Gets the master request. + * + * @return Request|null + * + * @deprecated since symfony/http-foundation 5.3, use getMainRequest() instead + */ + public function getMasterRequest() + { + trigger_deprecation('symfony/http-foundation', '5.3', '"%s()" is deprecated, use "getMainRequest()" instead.', __METHOD__); + + return $this->getMainRequest(); + } + /** * Returns the parent request of the current. * @@ -89,7 +101,7 @@ class RequestStack * might make it un-compatible with other features of your framework * like ESI support. * - * If current Request is the master request, it returns null. + * If current Request is the main request, it returns null. * * @return Request|null */ diff --git a/src/Symfony/Component/HttpFoundation/Session/SessionFactory.php b/src/Symfony/Component/HttpFoundation/Session/SessionFactory.php index a9982ed0c3..8f754dea76 100644 --- a/src/Symfony/Component/HttpFoundation/Session/SessionFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/SessionFactory.php @@ -35,6 +35,6 @@ class SessionFactory public function createSession(): SessionInterface { - return new Session($this->storageFactory->createStorage($this->requestStack->getMasterRequest()), null, null, $this->usageReporter); + return new Session($this->storageFactory->createStorage($this->requestStack->getMainRequest()), null, null, $this->usageReporter); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php index a84fb26f0b..3ee28918e2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php @@ -12,11 +12,14 @@ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; class RequestStackTest extends TestCase { + use ExpectDeprecationTrait; + public function testGetCurrentRequest() { $requestStack = new RequestStack(); @@ -33,6 +36,23 @@ class RequestStackTest extends TestCase $this->assertNull($requestStack->pop()); } + public function testGetMainRequest() + { + $requestStack = new RequestStack(); + $this->assertNull($requestStack->getMainRequest()); + + $mainRequest = Request::create('/foo'); + $subRequest = Request::create('/bar'); + + $requestStack->push($mainRequest); + $requestStack->push($subRequest); + + $this->assertSame($mainRequest, $requestStack->getMainRequest()); + } + + /** + * @group legacy + */ public function testGetMasterRequest() { $requestStack = new RequestStack(); @@ -44,6 +64,7 @@ class RequestStackTest extends TestCase $requestStack->push($masterRequest); $requestStack->push($subRequest); + $this->expectDeprecation('Since symfony/http-foundation 5.3: "Symfony\Component\HttpFoundation\RequestStack::getMasterRequest()" is deprecated, use "getMainRequest()" instead.'); $this->assertSame($masterRequest, $requestStack->getMasterRequest()); } @@ -52,15 +73,15 @@ class RequestStackTest extends TestCase $requestStack = new RequestStack(); $this->assertNull($requestStack->getParentRequest()); - $masterRequest = Request::create('/foo'); + $mainRequest = Request::create('/foo'); - $requestStack->push($masterRequest); + $requestStack->push($mainRequest); $this->assertNull($requestStack->getParentRequest()); $firstSubRequest = Request::create('/bar'); $requestStack->push($firstSubRequest); - $this->assertSame($masterRequest, $requestStack->getParentRequest()); + $this->assertSame($mainRequest, $requestStack->getParentRequest()); $secondSubRequest = Request::create('/baz'); diff --git a/src/Symfony/Component/HttpFoundation/UrlHelper.php b/src/Symfony/Component/HttpFoundation/UrlHelper.php index f114c0a9fb..0f417130af 100644 --- a/src/Symfony/Component/HttpFoundation/UrlHelper.php +++ b/src/Symfony/Component/HttpFoundation/UrlHelper.php @@ -35,7 +35,7 @@ final class UrlHelper return $path; } - if (null === $request = $this->requestStack->getMasterRequest()) { + if (null === $request = $this->requestStack->getMainRequest()) { return $this->getAbsoluteUrlFromContext($path); } @@ -64,7 +64,7 @@ final class UrlHelper return $path; } - if (null === $request = $this->requestStack->getMasterRequest()) { + if (null === $request = $this->requestStack->getMainRequest()) { return $path; } diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index 83da910aab..5b11f1cedd 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -9,6 +9,8 @@ CHANGELOG * Deprecate `ArgumentMetadata::getAttribute()`, use `getAttributes()` instead * Mark the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal * Deprecate returning a `ContainerBuilder` from `KernelInterface::registerContainerConfiguration()` + * Deprecate `HttpKernelInterface::MASTER_REQUEST` and add `HttpKernelInterface::MAIN_REQUEST` as replacement + * Deprecate `KernelEvent::isMasterRequest()` and add `isMainRequest()` as replacement 5.2.0 ----- diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index f8b5d8aa3a..2b008ae852 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -107,7 +107,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface } // Sub-requests and programmatic calls stay in the collected profile. - if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) { + if ($this->dumper || ($this->requestStack && $this->requestStack->getMainRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) { return; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index 27930fea09..238970568f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -42,7 +42,7 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter */ public function collect(Request $request, Response $response, \Throwable $exception = null) { - $this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null; + $this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null; $this->data = [ 'called_listeners' => [], 'not_called_listeners' => [], diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 877b6b5d76..70d0e216a4 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -46,7 +46,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte */ public function collect(Request $request, Response $response, \Throwable $exception = null) { - $this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null; + $this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null; } /** diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index ad6fe2efe4..b010562d9d 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -106,7 +106,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter 'session_metadata' => $sessionMetadata, 'session_attributes' => $sessionAttributes, 'session_usages' => array_values($this->sessionUsages), - 'stateless_check' => $this->requestStack && $this->requestStack->getMasterRequest()->attributes->get('_stateless', false), + 'stateless_check' => $this->requestStack && $this->requestStack->getMainRequest()->attributes->get('_stateless', false), 'flashes' => $flashes, 'path_info' => $request->getPathInfo(), 'controller' => 'n/a', @@ -374,7 +374,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 87672a9d19..55dcb52521 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -91,7 +91,7 @@ class FileLinkFormatter } if ($this->requestStack && $this->baseDir && $this->urlFormat) { - $request = $this->requestStack->getMasterRequest(); + $request = $this->requestStack->getMainRequest(); if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) { return [ diff --git a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php index 08558d533a..d0793f3624 100644 --- a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -28,7 +28,7 @@ class KernelEvent extends Event /** * @param int $requestType The request type the kernel is currently processing; one of - * HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST + * HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST */ public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType) { @@ -60,7 +60,7 @@ class KernelEvent extends Event /** * Returns the request type the kernel is currently processing. * - * @return int One of HttpKernelInterface::MASTER_REQUEST and + * @return int One of HttpKernelInterface::MAIN_REQUEST and * HttpKernelInterface::SUB_REQUEST */ public function getRequestType() @@ -68,13 +68,25 @@ class KernelEvent extends Event return $this->requestType; } + /** + * Checks if this is the main request. + */ + public function isMainRequest(): bool + { + return HttpKernelInterface::MAIN_REQUEST === $this->requestType; + } + /** * Checks if this is a master request. * * @return bool True if the request is a master request + * + * @deprecated since symfony/http-kernel 5.3, use isMainRequest() instead */ public function isMasterRequest() { - return HttpKernelInterface::MASTER_REQUEST === $this->requestType; + trigger_deprecation('symfony/http-kernel', '5.3', '"%s()" is deprecated, use "isMainRequest()" instead.'); + + return $this->isMainRequest(); } } diff --git a/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php b/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php index e0002fb56f..014ca535fe 100644 --- a/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/TerminateEvent.php @@ -18,8 +18,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to execute logic after a response was sent. * - * Since it's only triggered on master requests, the `getRequestType()` method - * will always return the value of `HttpKernelInterface::MASTER_REQUEST`. + * Since it's only triggered on main requests, the `getRequestType()` method + * will always return the value of `HttpKernelInterface::MAIN_REQUEST`. * * @author Jordi Boggiano */ @@ -29,7 +29,7 @@ final class TerminateEvent extends KernelEvent public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) { - parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + parent::__construct($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $this->response = $response; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php index 4244f46014..9b8891f79e 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php @@ -52,7 +52,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface public function onKernelRequest(RequestEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } @@ -69,7 +69,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } @@ -138,7 +138,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface public function onFinishRequest(FinishRequestEvent $event) { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { array_pop($this->sessionUsageStack); } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php index 19d13b8c46..0c88187d1e 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php @@ -41,7 +41,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface public function onKernelRequest(RequestEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } @@ -59,12 +59,12 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface } /** - * Checks if session was initialized and saves if current request is master + * Checks if session was initialized and saves if current request is the main request * Runs on 'kernel.response' in test environment. */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index df12569bfd..924cbb1fd1 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -76,7 +76,7 @@ class DebugHandlersListener implements EventSubscriberInterface if ($event instanceof ConsoleEvent && !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { return; } - if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMasterRequest()) { + if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMainRequest()) { return; } $this->firstCall = $this->hasTerminatedWithException = false; diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index 14c6aa63d1..c01d9ad491 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -65,7 +65,7 @@ class FragmentListener implements EventSubscriberInterface return; } - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { $this->validateRequest($request); } diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index 3143f2b9a6..a0e55563af 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -32,22 +32,22 @@ class ProfilerListener implements EventSubscriberInterface protected $profiler; protected $matcher; protected $onlyException; - protected $onlyMasterRequests; + protected $onlyMainRequests; protected $exception; protected $profiles; protected $requestStack; protected $parents; /** - * @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise - * @param bool $onlyMasterRequests True if the profiler only collects data when the request is a master request, false otherwise + * @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise + * @param bool $onlyMainRequests True if the profiler only collects data when the request is the main request, false otherwise */ - public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMasterRequests = false) + public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMainRequests = false) { $this->profiler = $profiler; $this->matcher = $matcher; $this->onlyException = $onlyException; - $this->onlyMasterRequests = $onlyMasterRequests; + $this->onlyMainRequests = $onlyMainRequests; $this->profiles = new \SplObjectStorage(); $this->parents = new \SplObjectStorage(); $this->requestStack = $requestStack; @@ -58,7 +58,7 @@ class ProfilerListener implements EventSubscriberInterface */ public function onKernelException(ExceptionEvent $event) { - if ($this->onlyMasterRequests && !$event->isMasterRequest()) { + if ($this->onlyMainRequests && !$event->isMainRequest()) { return; } @@ -70,8 +70,7 @@ class ProfilerListener implements EventSubscriberInterface */ public function onKernelResponse(ResponseEvent $event) { - $master = $event->isMasterRequest(); - if ($this->onlyMasterRequests && !$master) { + if ($this->onlyMainRequests && !$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php index d8292aec43..75ff2d00eb 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php @@ -36,7 +36,7 @@ class ResponseListener implements EventSubscriberInterface */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php index 2635788b1c..f2b950cef2 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SessionListener.php @@ -21,7 +21,7 @@ use Symfony\Component\HttpKernel\Event\RequestEvent; * * When the passed container contains a "session_storage" entry which * holds a NativeSessionStorage instance, the "cookie_secure" option - * will be set to true whenever the current master request is secure. + * will be set to true whenever the current main request is secure. * * @author Fabien Potencier * @@ -38,14 +38,14 @@ class SessionListener extends AbstractSessionListener { parent::onKernelRequest($event); - if (!$event->isMasterRequest() || !$this->container->has('session')) { + if (!$event->isMainRequest() || !$this->container->has('session')) { return; } if ($this->container->has('session_storage') && ($storage = $this->container->get('session_storage')) instanceof NativeSessionStorage - && ($masterRequest = $this->container->get('request_stack')->getMasterRequest()) - && $masterRequest->isSecure() + && ($mainRequest = $this->container->get('request_stack')->getMainRequest()) + && $mainRequest->isSecure() ) { $storage->setOptions(['cookie_secure' => true]); } diff --git a/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php b/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php index 730ee5453f..b3f7ca40fa 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php @@ -31,7 +31,7 @@ class StreamedResponseListener implements EventSubscriberInterface */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php index 2ef4af7aa3..9081bff652 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php @@ -38,7 +38,7 @@ class SurrogateListener implements EventSubscriberInterface */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php b/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php index 1f0c79822d..caa0f32aab 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php @@ -29,7 +29,7 @@ class ValidateRequestListener implements EventSubscriberInterface */ public function onKernelRequest(RequestEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } $request = $event->getRequest(); diff --git a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index a5544347dc..788fec3e94 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php @@ -66,7 +66,7 @@ class FragmentHandler * @return string|null The Response content or null when the Response is streamed * * @throws \InvalidArgumentException when the renderer does not exist - * @throws \LogicException when no master request is being handled + * @throws \LogicException when no main request is being handled */ public function render($uri, string $renderer = 'inline', array $options = []) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index f8f5a9ad78..18d9565ad4 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -44,7 +44,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * will try to carry on and deliver a meaningful response. * * * trace_level May be one of 'none', 'short' and 'full'. For 'short', a concise trace of the - * master request will be added as an HTTP header. 'full' will add traces for all + * main request will be added as an HTTP header. 'full' will add traces for all * requests (including ESI subrequests). (default: 'full' if in debug; 'none' otherwise) * * * trace_header Header name to use for traces. (default: X-Symfony-Cache) @@ -156,7 +156,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface } /** - * Gets the Request instance associated with the master request. + * Gets the Request instance associated with the main request. * * @return Request A Request instance */ @@ -190,10 +190,10 @@ class HttpCache implements HttpKernelInterface, TerminableInterface /** * {@inheritdoc} */ - public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true) + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true) { // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism - if (HttpKernelInterface::MASTER_REQUEST === $type) { + if (HttpKernelInterface::MAIN_REQUEST === $type) { $this->traces = []; // Keep a clone of the original request for surrogates so they can access it. // We must clone here to get a separate instance because the application will modify the request during @@ -224,12 +224,12 @@ class HttpCache implements HttpKernelInterface, TerminableInterface $this->restoreResponseBody($request, $response); - if (HttpKernelInterface::MASTER_REQUEST === $type) { + if (HttpKernelInterface::MAIN_REQUEST === $type) { $this->addTraces($response); } if (null !== $this->surrogate) { - if (HttpKernelInterface::MASTER_REQUEST === $type) { + if (HttpKernelInterface::MAIN_REQUEST === $type) { $this->surrogateCacheStrategy->update($response); } else { $this->surrogateCacheStrategy->add($response); @@ -474,7 +474,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface } // always a "master" request (as the real master request can be in cache) - $response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $catch); + $response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, $catch); /* * Support stale-if-error given on Responses or as a config option. diff --git a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php index 1f09946846..c9983f6114 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php @@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\Response; * ResponseCacheStrategy knows how to compute the Response cache HTTP header * based on the different response cache headers. * - * This implementation changes the master response TTL to the smallest TTL received + * This implementation changes the main response TTL to the smallest TTL received * or force validation if one of the surrogates has validation cache strategy. * * @author Fabien Potencier diff --git a/src/Symfony/Component/HttpKernel/HttpClientKernel.php b/src/Symfony/Component/HttpKernel/HttpClientKernel.php index 818082f439..58ca82e5a8 100644 --- a/src/Symfony/Component/HttpKernel/HttpClientKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpClientKernel.php @@ -42,7 +42,7 @@ final class HttpClientKernel implements HttpKernelInterface $this->client = $client ?? HttpClient::create(); } - public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true): Response + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response { $headers = $this->getHeaders($request); $body = ''; diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 850331349b..6875b484b5 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -71,7 +71,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface /** * {@inheritdoc} */ - public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true) + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true) { $request->headers->set('X-Php-Ob-Level', (string) ob_get_level()); @@ -104,11 +104,11 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface */ public function terminateWithException(\Throwable $exception, Request $request = null) { - if (!$request = $request ?: $this->requestStack->getMasterRequest()) { + if (!$request = $request ?: $this->requestStack->getMainRequest()) { throw $exception; } - $response = $this->handleThrowable($exception, $request, self::MASTER_REQUEST); + $response = $this->handleThrowable($exception, $request, self::MAIN_REQUEST); $response->sendHeaders(); $response->sendContent(); @@ -124,7 +124,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface * @throws \LogicException If one of the listener does not behave as expected * @throws NotFoundHttpException When controller cannot be found */ - private function handleRaw(Request $request, int $type = self::MASTER_REQUEST): Response + private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Response { $this->requestStack->push($request); diff --git a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php index 554585fb9c..6a1b6caaa4 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php +++ b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php @@ -60,7 +60,7 @@ class HttpKernelBrowser extends AbstractBrowser */ protected function doRequest($request) { - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); + $response = $this->kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, $this->catchExceptions); if ($this->kernel instanceof TerminableInterface) { $this->kernel->terminate($request, $response); diff --git a/src/Symfony/Component/HttpKernel/HttpKernelInterface.php b/src/Symfony/Component/HttpKernel/HttpKernelInterface.php index c469a22b81..f9685faf1f 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernelInterface.php +++ b/src/Symfony/Component/HttpKernel/HttpKernelInterface.php @@ -21,9 +21,15 @@ use Symfony\Component\HttpFoundation\Response; */ interface HttpKernelInterface { - public const MASTER_REQUEST = 1; + public const MAIN_REQUEST = 1; public const SUB_REQUEST = 2; + /** + * @deprecated since symfony/http-kernel 5.3, use MAIN_REQUEST instead. + * To ease the migration, this constant won't be removed until Symfony 7.0. + */ + public const MASTER_REQUEST = self::MAIN_REQUEST; + /** * Handles a Request to convert it to a Response. * @@ -31,12 +37,12 @@ interface HttpKernelInterface * and do its best to convert them to a Response instance. * * @param int $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) + * (one of HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST) * @param bool $catch Whether to catch exceptions or not * * @return Response A Response instance * * @throws \Exception When an Exception occurs during processing */ - public function handle(Request $request, int $type = self::MASTER_REQUEST, bool $catch = true); + public function handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true); } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index f0ce754f20..dbe5a111da 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -177,7 +177,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl /** * {@inheritdoc} */ - public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true) + public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true) { if (!$this->booted) { $container = $this->container ?? $this->preBoot(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 4204b8ef03..864f6f1458 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -45,11 +45,11 @@ class LoggerDataCollectorTest extends TestCase ], $compilerLogs['Unknown Compiler Pass']); } - public function testWithMasterRequest() + public function testWithMainRequest() { - $masterRequest = new Request(); + $mainRequest = new Request(); $stack = new RequestStack(); - $stack->push($masterRequest); + $stack->push($mainRequest); $logger = $this ->getMockBuilder(DebugLoggerInterface::class) @@ -60,16 +60,16 @@ class LoggerDataCollectorTest extends TestCase $c = new LoggerDataCollector($logger, __DIR__.'/', $stack); - $c->collect($masterRequest, new Response()); + $c->collect($mainRequest, new Response()); $c->lateCollect(); } public function testWithSubRequest() { - $masterRequest = new Request(); + $mainRequest = new Request(); $subRequest = new Request(); $stack = new RequestStack(); - $stack->push($masterRequest); + $stack->push($mainRequest); $stack->push($subRequest); $logger = $this diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index bfc29eb109..2b8b38501e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -210,7 +210,7 @@ class RequestDataCollectorTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $c = new RequestDataCollector(); - $c->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse())); + $c->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $this->createResponse())); $this->assertTrue($request->attributes->get('_redirected')); } @@ -374,7 +374,7 @@ class RequestDataCollectorTest extends TestCase { $resolver = $this->createMock(ControllerResolverInterface::class); $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->createMock(ArgumentResolverInterface::class)); - $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MAIN_REQUEST); $collector->onKernelController($event); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index da07de1ca3..d15820eb54 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -70,7 +70,7 @@ class DebugHandlersListenerTest extends TestCase $event = new KernelEvent( $this->createMock(HttpKernelInterface::class), Request::create('/'), - HttpKernelInterface::MASTER_REQUEST + HttpKernelInterface::MAIN_REQUEST ); $exception = null; diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php index 6534ebf4e2..39bdfd6292 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php @@ -29,7 +29,7 @@ class DisallowRobotsIndexingListenerTest extends TestCase $response = new Response(...$responseArgs); $listener = new DisallowRobotsIndexingListener(); - $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MAIN_REQUEST, $response); $listener->onResponse($event); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php index 78f33e0493..bd4b179935 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php @@ -105,8 +105,8 @@ class ErrorListenerTest extends TestCase $request = new Request(); $exception = new \Exception('foo'); - $event = new ExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); - $event2 = new ExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); + $event = new ExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MAIN_REQUEST, $exception); + $event2 = new ExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MAIN_REQUEST, $exception); return [ [$event, $event2], @@ -125,7 +125,7 @@ class ErrorListenerTest extends TestCase $request = Request::create('/'); $request->setRequestFormat('xml'); - $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); + $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new \Exception('foo')); $listener->onKernelException($event); $response = $event->getResponse(); @@ -145,13 +145,13 @@ class ErrorListenerTest extends TestCase $dispatcher->addSubscriber($listener); $request = Request::create('/'); - $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); + $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new \Exception('foo')); $dispatcher->dispatch($event, KernelEvents::EXCEPTION); $response = new Response('', 200, ['content-security-policy' => "style-src 'self'"]); $this->assertTrue($response->headers->has('content-security-policy')); - $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response); $dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); @@ -174,7 +174,7 @@ class ErrorListenerTest extends TestCase return $controller(...$event->getArguments()); }); - $event = new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); + $event = new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, new \Exception('foo')); $listener->onKernelException($event); $this->assertSame('OK: foo', $event->getResponse()->getContent()); @@ -208,7 +208,7 @@ class TestLogger extends Logger implements DebugLoggerInterface class TestKernel implements HttpKernelInterface { - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response + public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response { return new Response('foo'); } @@ -216,7 +216,7 @@ class TestKernel implements HttpKernelInterface class TestKernelThatThrowsException implements HttpKernelInterface { - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response + public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response { throw new \RuntimeException('bar'); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index 5720420dbf..77d07a39f3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -112,7 +112,7 @@ class FragmentListenerTest extends TestCase $this->assertFalse($request->query->has('_path')); } - private function createRequestEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) + private function createRequestEvent(Request $request, int $requestType = HttpKernelInterface::MAIN_REQUEST): RequestEvent { return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, $requestType); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php index ab92a79168..3c89cafd04 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php @@ -40,7 +40,7 @@ class LocaleAwareListenerTest extends TestCase ->method('setLocale') ->with($this->equalTo('fr')); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MAIN_REQUEST); $this->listener->onKernelRequest($event); } @@ -57,7 +57,7 @@ class LocaleAwareListenerTest extends TestCase $this->throwException(new \InvalidArgumentException()) ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MAIN_REQUEST); $this->listener->onKernelRequest($event); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index 186ce43b1d..5e4f56f1fc 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -100,7 +100,7 @@ class LocaleListenerTest extends TestCase $this->requestStack->expects($this->once())->method('getParentRequest')->willReturn($parentRequest); - $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST); $listener = new LocaleListener($this->requestStack, 'fr', $router); $listener->onKernelFinishRequest($event); @@ -119,6 +119,6 @@ class LocaleListenerTest extends TestCase private function getEvent(Request $request): RequestEvent { - return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 8f7aca2a00..10733d47e3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -28,7 +28,7 @@ use Symfony\Component\HttpKernel\Profiler\Profiler; class ProfilerListenerTest extends TestCase { /** - * Test a master and sub request with an exception and `onlyException` profiler option enabled. + * Test a main and sub request with an exception and `onlyException` profiler option enabled. */ public function testKernelTerminate() { @@ -40,23 +40,23 @@ class ProfilerListenerTest extends TestCase ->willReturn($profile); $kernel = $this->createMock(HttpKernelInterface::class); - $masterRequest = $this->createMock(Request::class); + $mainRequest = $this->createMock(Request::class); $subRequest = $this->createMock(Request::class); $response = $this->createMock(Response::class); $requestStack = new RequestStack(); - $requestStack->push($masterRequest); + $requestStack->push($mainRequest); $onlyException = true; $listener = new ProfilerListener($profiler, $requestStack, null, $onlyException); - // master request - $listener->onKernelResponse(new ResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response)); + // main request + $listener->onKernelResponse(new ResponseEvent($kernel, $mainRequest, Kernel::MAIN_REQUEST, $response)); // sub request $listener->onKernelException(new ExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404))); $listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response)); - $listener->onKernelTerminate(new TerminateEvent($kernel, $masterRequest, $response)); + $listener->onKernelTerminate(new TerminateEvent($kernel, $mainRequest, $response)); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php index 6c5af2a6dd..ee6ff64133 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php @@ -58,7 +58,7 @@ class ResponseListenerTest extends TestCase $response = new Response('foo'); - $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, $response); $this->dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertEquals('ISO-8859-15', $response->getCharset()); @@ -72,7 +72,7 @@ class ResponseListenerTest extends TestCase $response = new Response('foo'); $response->setCharset('ISO-8859-1'); - $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, $response); $this->dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertEquals('ISO-8859-1', $response->getCharset()); @@ -87,7 +87,7 @@ class ResponseListenerTest extends TestCase $request = Request::create('/'); $request->setRequestFormat('application/json'); - $event = new ResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response); $this->dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertEquals('ISO-8859-15', $response->getCharset()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 453bf5b0e3..7b2ed964af 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -83,7 +83,7 @@ class RouterListenerTest extends TestCase $request = Request::create($uri); $request->attributes->set('_controller', null); // Prevents going in to routing process - return new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + return new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); } public function testInvalidMatcher() @@ -96,7 +96,7 @@ class RouterListenerTest extends TestCase { $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/'); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->once()) @@ -112,7 +112,7 @@ class RouterListenerTest extends TestCase { $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/', 'post'); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->any()) @@ -154,7 +154,7 @@ class RouterListenerTest extends TestCase $request = Request::create('http://localhost/'); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); } public function getLoggingParameterData() @@ -214,7 +214,7 @@ class RouterListenerTest extends TestCase $this->expectException(BadRequestHttpException::class); $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://bad host %22/'); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $requestMatcher = $this->createMock(RequestMatcherInterface::class); @@ -243,7 +243,7 @@ class RouterListenerTest extends TestCase $request = Request::create('https://www.symfony.com/path'); $request->headers->set('referer', 'https://www.google.com'); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $listener = new RouterListener($urlMatcher, $this->requestStack); $listener->onKernelRequest($event); @@ -269,7 +269,7 @@ class RouterListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('https://www.symfony.com/path'); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $listener = new RouterListener($urlMatcher, $this->requestStack); $listener->onKernelRequest($event); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php index ac6175d98f..336a77c8f6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php @@ -32,11 +32,11 @@ use Symfony\Component\HttpKernel\KernelInterface; class SessionListenerTest extends TestCase { - public function testOnlyTriggeredOnMasterRequest() + public function testOnlyTriggeredOnMainRequest() { $listener = $this->getMockForAbstractClass(AbstractSessionListener::class); $event = $this->createMock(RequestEvent::class); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); + $event->expects($this->once())->method('isMainRequest')->willReturn(false); $event->expects($this->never())->method('getRequest'); // sub request @@ -48,7 +48,7 @@ class SessionListenerTest extends TestCase $session = $this->createMock(Session::class); $requestStack = $this->createMock(RequestStack::class); - $requestStack->expects($this->once())->method('getMasterRequest')->willReturn(null); + $requestStack->expects($this->once())->method('getMainRequest')->willReturn(null); $sessionStorage = $this->createMock(NativeSessionStorage::class); $sessionStorage->expects($this->never())->method('setOptions')->with(['cookie_secure' => true]); @@ -62,7 +62,7 @@ class SessionListenerTest extends TestCase $listener = new SessionListener($container); $event = $this->createMock(RequestEvent::class); - $event->expects($this->exactly(2))->method('isMasterRequest')->willReturn(true); + $event->expects($this->exactly(2))->method('isMainRequest')->willReturn(true); $event->expects($this->once())->method('getRequest')->willReturn($request); $listener->onKernelRequest($event); @@ -83,10 +83,10 @@ class SessionListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); $response = new Response(); - $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response)); $this->assertTrue($response->headers->has('Expires')); $this->assertTrue($response->headers->hasCacheControlDirective('private')); @@ -108,12 +108,12 @@ class SessionListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); $response = new Response(); $response->setSharedMaxAge(60); $response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true'); - $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response)); $this->assertTrue($response->headers->hasCacheControlDirective('public')); $this->assertFalse($response->headers->has('Expires')); @@ -135,7 +135,7 @@ class SessionListenerTest extends TestCase ]); $listener = new SessionListener($container); - $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response)); $this->assertFalse($response->headers->has('Expires')); $this->assertTrue($response->headers->hasCacheControlDirective('public')); $this->assertFalse($response->headers->hasCacheControlDirective('private')); @@ -144,7 +144,7 @@ class SessionListenerTest extends TestCase $this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER)); } - public function testSurrogateMasterRequestIsPublic() + public function testSurrogateMainRequestIsPublic() { $session = $this->createMock(Session::class); $session->expects($this->exactly(4))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1, 1, 1)); @@ -159,21 +159,21 @@ class SessionListenerTest extends TestCase $request = new Request(); $response = new Response(); $response->setCache(['public' => true, 'max_age' => '30']); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); $this->assertTrue($request->hasSession()); $subRequest = clone $request; $this->assertSame($request->getSession(), $subRequest->getSession()); - $listener->onKernelRequest(new RequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST)); - $listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response)); - $listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $subRequest, HttpKernelInterface::MAIN_REQUEST)); + $listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, HttpKernelInterface::MAIN_REQUEST, $response)); + $listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MAIN_REQUEST)); $this->assertFalse($response->headers->has('Expires')); $this->assertFalse($response->headers->hasCacheControlDirective('private')); $this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate')); $this->assertSame('30', $response->headers->getCacheControlDirective('max-age')); - $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response)); $this->assertTrue($response->headers->hasCacheControlDirective('private')); $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); @@ -194,14 +194,14 @@ class SessionListenerTest extends TestCase ->with(['cookie_secure' => true]); $requestStack = new RequestStack(); - $requestStack->push($masterRequest = new Request([], [], [], [], [], ['HTTPS' => 'on'])); + $requestStack->push($mainRequest = new Request([], [], [], [], [], ['HTTPS' => 'on'])); $container = new Container(); $container->set('session_storage', $sessionStorage); $container->set('session', $session); $container->set('request_stack', $requestStack); - $event = new RequestEvent($kernel, $masterRequest, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $mainRequest, HttpKernelInterface::MAIN_REQUEST); $listener = new SessionListener($container); $listener->onKernelRequest($event); @@ -210,10 +210,10 @@ class SessionListenerTest extends TestCase $container->set('session_storage', null); $sessionStorage = null; - $subRequest = $masterRequest->duplicate(); - // at this point both master and subrequest have a closure to build the session + $subRequest = $mainRequest->duplicate(); + // at this point both main and subrequest have a closure to build the session - $masterRequest->getSession(); + $mainRequest->getSession(); // calling the factory on the subRequest should not trigger a second call to storage->setOptions() $subRequest->getSession(); @@ -232,10 +232,10 @@ class SessionListenerTest extends TestCase $request = new Request(); $request->attributes->set('_stateless', true); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); $this->expectException(UnexpectedSessionUsageException::class); - $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new Response())); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new Response())); } public function testSessionUsageLogIfStatelessAndSessionUsed() @@ -255,9 +255,9 @@ class SessionListenerTest extends TestCase $request = new Request(); $request->attributes->set('_stateless', true); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); - $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new Response())); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new Response())); } public function testSessionIsSavedWhenUnexpectedSessionExceptionThrown() @@ -276,11 +276,11 @@ class SessionListenerTest extends TestCase $request = new Request(); $request->attributes->set('_stateless', true); - $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST)); $response = new Response(); $this->expectException(UnexpectedSessionUsageException::class); - $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response)); } public function testSessionUsageCallbackWhenDebugAndStateless() diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php index fc7e4d83ac..88a442a928 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php @@ -45,7 +45,7 @@ class SurrogateListenerTest extends TestCase $listener = new SurrogateListener(new Esi()); $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response); $dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control')); @@ -59,7 +59,7 @@ class SurrogateListenerTest extends TestCase $listener = new SurrogateListener(new Esi()); $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response); $dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control')); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index 2ec6581694..45a154a18b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -51,7 +51,7 @@ class TestSessionListenerTest extends TestCase ->willReturn($this->session); } - public function testShouldSaveMasterRequestSession() + public function testShouldSaveMainRequestSession() { $this->sessionHasBeenStarted(); $this->sessionMustBeSaved(); @@ -72,7 +72,7 @@ class TestSessionListenerTest extends TestCase @ini_set('session.cookie_lifetime', 0); - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); + $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); $cookies = $response->headers->getCookies(); $this->assertEquals(0, reset($cookies)->getExpiresTime()); @@ -86,7 +86,7 @@ class TestSessionListenerTest extends TestCase $this->sessionHasBeenStarted(); $this->sessionIsEmpty(); - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); + $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); $this->assertSame([], $response->headers->getCookies()); } @@ -99,10 +99,10 @@ class TestSessionListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $this->listener->onKernelRequest($event); - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); + $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST); $this->assertNotEmpty($response->headers->getCookies()); } @@ -118,12 +118,12 @@ class TestSessionListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $this->listener->onKernelRequest($event); $response = new Response('', 200, ['Set-Cookie' => $existing]); - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST, $response); + $response = $this->filterResponse(new Request(), HttpKernelInterface::MAIN_REQUEST, $response); $this->assertSame($expected, $response->headers->all()['set-cookie']); } @@ -148,14 +148,14 @@ class TestSessionListenerTest extends TestCase public function testDoesNotThrowIfRequestDoesNotHaveASession() { $kernel = $this->createMock(HttpKernelInterface::class); - $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response()); + $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, new Response()); $this->listener->onKernelResponse($event); $this->assertTrue(true); } - private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, Response $response = null) + private function filterResponse(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, Response $response = null) { $request->setSession($this->session); $response = $response ?: new Response(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php index d23832d80a..5b02995dc3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php @@ -27,7 +27,7 @@ class ValidateRequestListenerTest extends TestCase Request::setTrustedProxies([], -1); } - public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() + public function testListenerThrowsWhenMainRequestHasInconsistentClientIps() { $this->expectException(ConflictingHeadersException::class); $dispatcher = new EventDispatcher(); @@ -40,7 +40,7 @@ class ValidateRequestListenerTest extends TestCase $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); $dispatcher->addListener(KernelEvents::REQUEST, [new ValidateRequestListener(), 'onKernelRequest']); - $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST); $dispatcher->dispatch($event, KernelEvents::REQUEST); } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 1aead50bf4..3ac93a62d7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1209,7 +1209,7 @@ class HttpCacheTest extends HttpCacheTestCase $responses = [ [ 'status' => 200, - 'body' => 'I am a long-lived master response, but I embed a short-lived resource: ', + 'body' => 'I am a long-lived main response, but I embed a short-lived resource: ', 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', @@ -1267,7 +1267,7 @@ class HttpCacheTest extends HttpCacheTestCase $responses = [ [ 'status' => 200, - 'body' => 'I am the master response and use expiration caching, but I embed another resource: ', + 'body' => 'I am the main response and use expiration caching, but I embed another resource: ', 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', @@ -1511,7 +1511,7 @@ class HttpCacheTest extends HttpCacheTestCase $request->server->set('REMOTE_ADDR', '10.0.0.1'); // Main request - $cache->handle($request, HttpKernelInterface::MASTER_REQUEST); + $cache->handle($request, HttpKernelInterface::MAIN_REQUEST); // Main request was now modified by HttpCache // The surrogate will ask for the request using $this->cache->getRequest() @@ -1734,7 +1734,7 @@ class TestKernel implements HttpKernelInterface $this->terminateCalled = true; } - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response + public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response { } } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php index a058a15f15..e47631d178 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php @@ -131,7 +131,7 @@ class HttpCacheTestCase extends TestCase $this->request = Request::create($uri, $method, [], $cookies, [], $server); $this->request->headers->add($headers); - $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); + $this->response = $this->cache->handle($this->request, HttpKernelInterface::MAIN_REQUEST, $this->catch); $this->responses[] = $this->response; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php index 62179ba154..3927684eb6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -58,7 +58,7 @@ class ResponseCacheStrategyTest extends TestCase $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage')); } - public function testSharedMaxAgeNotSetIfNotSetInMasterRequest() + public function testSharedMaxAgeNotSetIfNotSetInMainRequest() { $cacheStrategy = new ResponseCacheStrategy(); @@ -76,7 +76,7 @@ class ResponseCacheStrategyTest extends TestCase $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage')); } - public function testMasterResponseNotCacheableWhenEmbeddedResponseRequiresValidation() + public function testMainResponseNotCacheableWhenEmbeddedResponseRequiresValidation() { $cacheStrategy = new ResponseCacheStrategy(); @@ -84,66 +84,66 @@ class ResponseCacheStrategyTest extends TestCase $embeddedResponse->setLastModified(new \DateTime()); $cacheStrategy->add($embeddedResponse); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $cacheStrategy->update($masterResponse); + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($masterResponse->isFresh()); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('must-revalidate')); + $this->assertFalse($mainResponse->isFresh()); } - public function testValidationOnMasterResponseIsNotPossibleWhenItContainsEmbeddedResponses() + public function testValidationOnMainResponseIsNotPossibleWhenItContainsEmbeddedResponses() { $cacheStrategy = new ResponseCacheStrategy(); - // This master response uses the "validation" model - $masterResponse = new Response(); - $masterResponse->setLastModified(new \DateTime()); - $masterResponse->setEtag('foo'); + // This main response uses the "validation" model + $mainResponse = new Response(); + $mainResponse->setLastModified(new \DateTime()); + $mainResponse->setEtag('foo'); // Embedded response uses "expiry" model $embeddedResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); + $mainResponse->setSharedMaxAge(3600); $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertFalse($masterResponse->isValidateable()); - $this->assertFalse($masterResponse->headers->has('Last-Modified')); - $this->assertFalse($masterResponse->headers->has('ETag')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); + $this->assertFalse($mainResponse->isValidateable()); + $this->assertFalse($mainResponse->headers->has('Last-Modified')); + $this->assertFalse($mainResponse->headers->has('ETag')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('must-revalidate')); } - public function testMasterResponseWithValidationIsUnchangedWhenThereIsNoEmbeddedResponse() + public function testMainResponseWithValidationIsUnchangedWhenThereIsNoEmbeddedResponse() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setLastModified(new \DateTime()); - $cacheStrategy->update($masterResponse); + $mainResponse = new Response(); + $mainResponse->setLastModified(new \DateTime()); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->isValidateable()); + $this->assertTrue($mainResponse->isValidateable()); } - public function testMasterResponseWithExpirationIsUnchangedWhenThereIsNoEmbeddedResponse() + public function testMainResponseWithExpirationIsUnchangedWhenThereIsNoEmbeddedResponse() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $cacheStrategy->update($masterResponse); + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->isFresh()); + $this->assertTrue($mainResponse->isFresh()); } - public function testMasterResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable() + public function testMainResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); // Public, cacheable + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); // Public, cacheable /* This response has no validation or expiration information. That makes it uncacheable, it is always stale. @@ -152,19 +152,19 @@ class ResponseCacheStrategyTest extends TestCase $this->assertFalse($embeddedResponse->isFresh()); // not fresh, as no lifetime is provided $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($masterResponse->isFresh()); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('must-revalidate')); + $this->assertFalse($mainResponse->isFresh()); } public function testEmbeddingPrivateResponseMakesMainResponsePrivate() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); // public, cacheable + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); // public, cacheable // The embedded response might for example contain per-user data that remains valid for 60 seconds $embeddedResponse = new Response(); @@ -172,29 +172,29 @@ class ResponseCacheStrategyTest extends TestCase $embeddedResponse->setMaxAge(60); // this would implicitly set "private" as well, but let's be explicit $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('public')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('private')); + $this->assertFalse($mainResponse->headers->hasCacheControlDirective('public')); } public function testEmbeddingPublicResponseDoesNotMakeMainResponsePublic() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setPrivate(); // this is the default, but let's be explicit - $masterResponse->setMaxAge(100); + $mainResponse = new Response(); + $mainResponse->setPrivate(); // this is the default, but let's be explicit + $mainResponse->setMaxAge(100); $embeddedResponse = new Response(); $embeddedResponse->setPublic(); $embeddedResponse->setSharedMaxAge(100); $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('public')); + $this->assertTrue($mainResponse->headers->hasCacheControlDirective('private')); + $this->assertFalse($mainResponse->headers->hasCacheControlDirective('public')); } public function testResponseIsExiprableWhenEmbeddedResponseCombinesExpiryAndValidation() @@ -206,36 +206,36 @@ class ResponseCacheStrategyTest extends TestCase */ $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); $embeddedResponse = new Response(); $embeddedResponse->setSharedMaxAge(60); $embeddedResponse->setEtag('foo'); $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertEqualsWithDelta(60, (int) $masterResponse->headers->getCacheControlDirective('s-maxage'), 1); + $this->assertEqualsWithDelta(60, (int) $mainResponse->headers->getCacheControlDirective('s-maxage'), 1); } - public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombinesExpirationAndValidation() + public function testResponseIsExpirableButNotValidateableWhenMainResponseCombinesExpirationAndValidation() { $cacheStrategy = new ResponseCacheStrategy(); - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $masterResponse->setEtag('foo'); - $masterResponse->setLastModified(new \DateTime()); + $mainResponse = new Response(); + $mainResponse->setSharedMaxAge(3600); + $mainResponse->setEtag('foo'); + $mainResponse->setLastModified(new \DateTime()); $embeddedResponse = new Response(); $embeddedResponse->setSharedMaxAge(60); $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); + $cacheStrategy->update($mainResponse); - $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); - $this->assertFalse($masterResponse->isValidateable()); + $this->assertSame('60', $mainResponse->headers->getCacheControlDirective('s-maxage')); + $this->assertFalse($mainResponse->isValidateable()); } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php index ea2d2b7a12..7ab9b6c45f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SubRequestHandlerTest.php @@ -51,7 +51,7 @@ class SubRequestHandlerTest extends TestCase $this->assertSame('https', $request->headers->get('X-Forwarded-Proto')); }); - SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MAIN_REQUEST, true); $this->assertSame($globalState, $this->getGlobalState()); } @@ -75,7 +75,7 @@ class SubRequestHandlerTest extends TestCase $this->assertSame('for="10.0.0.1";host="localhost";proto=http', $request->headers->get('Forwarded')); }); - SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MAIN_REQUEST, true); $this->assertSame(self::$globalState, $this->getGlobalState()); } @@ -97,7 +97,7 @@ class SubRequestHandlerTest extends TestCase $this->assertSame(1234, $request->getPort()); }); - SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MAIN_REQUEST, true); $this->assertSame($globalState, $this->getGlobalState()); } @@ -120,7 +120,7 @@ class SubRequestHandlerTest extends TestCase $this->assertSame('https', $request->getScheme()); }); - SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MAIN_REQUEST, true); $this->assertSame($globalState, $this->getGlobalState()); } @@ -143,7 +143,7 @@ class TestSubRequestHandlerKernel implements HttpKernelInterface $this->assertCallback = $assertCallback; } - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response + public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = true): Response { $assertCallback = $this->assertCallback; $assertCallback($request, $type, $catch); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index 7f05fb8b89..471212f5e3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -54,7 +54,7 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface, } } - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false): Response + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = false): Response { $this->catch = $catch; $this->backendRequest = [Request::getTrustedProxies(), Request::getTrustedHeaderSet(), $request]; diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php index cef672e1f8..a8436d4b45 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php @@ -43,7 +43,7 @@ class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInt return $this->backendRequest; } - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false): Response + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = false): Response { $this->backendRequest = $request; diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 8ae6a66149..91636ba86c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -37,7 +37,7 @@ class HttpKernelTest extends TestCase $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, true); } public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() @@ -45,7 +45,7 @@ class HttpKernelTest extends TestCase $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, false); } public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithAHandlingListener() @@ -56,7 +56,7 @@ class HttpKernelTest extends TestCase }); $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException('foo'); }); - $response = $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + $response = $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, true); $this->assertEquals('500', $response->getStatusCode()); $this->assertEquals('foo', $response->getContent()); @@ -74,7 +74,7 @@ class HttpKernelTest extends TestCase $kernel = $this->getHttpKernel($dispatcher, function () use ($exception) { throw $exception; }); try { - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); + $kernel->handle(new Request(), HttpKernelInterface::MAIN_REQUEST, true); $this->fail('LogicException expected'); } catch (\RuntimeException $e) { $this->assertSame($exception, $e); @@ -313,10 +313,10 @@ class HttpKernelTest extends TestCase $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, null, $stack); - $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST); + $kernel->handle($request, HttpKernelInterface::MAIN_REQUEST); } - public function testInconsistentClientIpsOnMasterRequests() + public function testInconsistentClientIpsOnMainRequests() { $this->expectException(BadRequestHttpException::class); $request = new Request(); @@ -331,7 +331,7 @@ class HttpKernelTest extends TestCase }); $kernel = $this->getHttpKernel($dispatcher); - $kernel->handle($request, $kernel::MASTER_REQUEST, false); + $kernel->handle($request, $kernel::MAIN_REQUEST, false); Request::setTrustedProxies([], -1); } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 50a6a29b96..e4df69e867 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -190,7 +190,7 @@ class KernelTest extends TestCase public function testHandleCallsHandleOnHttpKernel() { - $type = HttpKernelInterface::MASTER_REQUEST; + $type = HttpKernelInterface::MAIN_REQUEST; $catch = true; $request = new Request(); @@ -212,7 +212,7 @@ class KernelTest extends TestCase public function testHandleBootsTheKernel() { - $type = HttpKernelInterface::MASTER_REQUEST; + $type = HttpKernelInterface::MAIN_REQUEST; $catch = true; $request = new Request(); @@ -678,7 +678,7 @@ class TestKernel implements HttpKernelInterface $this->terminateCalled = true; } - public function handle(Request $request, int $type = self::MASTER_REQUEST, bool $catch = true): Response + public function handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Response { } diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index e58068299f..fb8757ade3 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -21,7 +21,7 @@ "symfony/error-handler": "^4.4|^5.0", "symfony/event-dispatcher": "^5.0", "symfony/http-client-contracts": "^1.1|^2", - "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-foundation": "^5.3", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.15", diff --git a/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php b/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php index 31a39b06bf..eecb3eb8ae 100644 --- a/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php +++ b/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php @@ -34,7 +34,7 @@ class CsrfTokenManager implements CsrfTokenManagerInterface * @param string|RequestStack|callable|null $namespace * * null: generates a namespace using $_SERVER['HTTPS'] * * string: uses the given string - * * RequestStack: generates a namespace using the current master request + * * RequestStack: generates a namespace using the current main request * * callable: uses the result of this callable (must return a string) */ public function __construct(TokenGeneratorInterface $generator = null, TokenStorageInterface $storage = null, $namespace = null) @@ -50,7 +50,7 @@ class CsrfTokenManager implements CsrfTokenManagerInterface $this->namespace = $superGlobalNamespaceGenerator; } elseif ($namespace instanceof RequestStack) { $this->namespace = function () use ($namespace, $superGlobalNamespaceGenerator) { - if ($request = $namespace->getMasterRequest()) { + if ($request = $namespace->getMainRequest()) { return $request->isSecure() ? 'https-' : ''; } diff --git a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php index aa473bc0aa..96d21b0803 100644 --- a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php +++ b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php @@ -66,11 +66,20 @@ final class LazyResponseEvent extends RequestEvent return $this->event->getRequestType(); } + /** + * {@inheritdoc} + */ + public function isMainRequest(): bool + { + return $this->event->isMainRequest(); + } /** * {@inheritdoc} */ public function isMasterRequest(): bool { - return $this->event->isMasterRequest(); + trigger_deprecation('symfony/security-http', '5.3', '"%s()" is deprecated, use "isMainRequest()" instead.'); + + return $this->event->isMainRequest(); } } diff --git a/src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php b/src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php index d59b46e619..e739de7125 100644 --- a/src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php +++ b/src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php @@ -42,7 +42,7 @@ final class LoginThrottlingListener implements EventSubscriberInterface return; } - $request = $this->requestStack->getMasterRequest(); + $request = $this->requestStack->getMainRequest(); $request->attributes->set(Security::LAST_USERNAME, $passport->getBadge(UserBadge::class)->getUserIdentifier()); $limit = $this->limiter->consume($request); diff --git a/src/Symfony/Component/Security/Http/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index 03661d843a..49b2b9a0d4 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -43,7 +43,7 @@ class Firewall implements EventSubscriberInterface public function onKernelRequest(RequestEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 66b54d325b..a3511067ac 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -86,7 +86,7 @@ class ContextListener extends AbstractListener */ public function authenticate(RequestEvent $event) { - if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) { + if (!$this->registered && null !== $this->dispatcher && $event->isMainRequest()) { $this->dispatcher->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']); $this->registered = true; } @@ -153,7 +153,7 @@ class ContextListener extends AbstractListener */ public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/Security/Http/RememberMe/ResponseListener.php b/src/Symfony/Component/Security/Http/RememberMe/ResponseListener.php index dcbb7218a2..ba2a86c2a1 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/ResponseListener.php +++ b/src/Symfony/Component/Security/Http/RememberMe/ResponseListener.php @@ -26,7 +26,7 @@ class ResponseListener implements EventSubscriberInterface { public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php index 411b004793..525456b59e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -74,7 +74,7 @@ class AccessListenerTest extends TestCase $this->createMock(AuthenticationManagerInterface::class) ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenTheTokenIsNotAuthenticated() @@ -138,7 +138,7 @@ class AccessListenerTest extends TestCase $authManager ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() @@ -173,7 +173,7 @@ class AccessListenerTest extends TestCase $this->createMock(AuthenticationManagerInterface::class) ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenAccessMapReturnsEmptyAttributes() @@ -201,7 +201,7 @@ class AccessListenerTest extends TestCase $this->createMock(AuthenticationManagerInterface::class) ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener(new LazyResponseEvent($event)); } @@ -233,7 +233,7 @@ class AccessListenerTest extends TestCase $this->createMock(AuthenticationManagerInterface::class) ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenTheSecurityTokenStorageHasNoTokenAndExceptionOnTokenIsFalse() @@ -263,7 +263,7 @@ class AccessListenerTest extends TestCase false ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenPublicAccessIsAllowedAndExceptionOnTokenIsFalse() @@ -292,7 +292,7 @@ class AccessListenerTest extends TestCase false ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWhenPublicAccessWhileAuthenticated() @@ -323,7 +323,7 @@ class AccessListenerTest extends TestCase false ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } public function testHandleMWithultipleAttributesShouldBeHandledAsAnd() @@ -363,6 +363,6 @@ class AccessListenerTest extends TestCase $this->createMock(AuthenticationManagerInterface::class) ); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index 522e0abc1c..fa430acfab 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -44,7 +44,7 @@ class AnonymousAuthenticationListenerTest extends TestCase ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST)); } public function testHandleWithTokenStorageHavingNoToken() @@ -75,7 +75,7 @@ class AnonymousAuthenticationListenerTest extends TestCase ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST)); } public function testHandledEventIsLogged() @@ -90,6 +90,6 @@ class AnonymousAuthenticationListenerTest extends TestCase $authenticationManager = $this->createMock(AuthenticationManagerInterface::class); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST)); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index b31576134b..a48c8f7cb0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -112,7 +112,7 @@ class ContextListenerTest extends TestCase $event = new ResponseEvent( $this->createMock(HttpKernelInterface::class), $request, - HttpKernelInterface::MASTER_REQUEST, + HttpKernelInterface::MAIN_REQUEST, new Response() ); @@ -131,7 +131,7 @@ class ContextListenerTest extends TestCase $event = new ResponseEvent( $this->createMock(HttpKernelInterface::class), $request, - HttpKernelInterface::MASTER_REQUEST, + HttpKernelInterface::MAIN_REQUEST, new Response() ); @@ -192,7 +192,7 @@ class ContextListenerTest extends TestCase $listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher); $event->expects($this->any()) - ->method('isMasterRequest') + ->method('isMainRequest') ->willReturn(true); $event->expects($this->any()) ->method('getRequest') @@ -221,7 +221,7 @@ class ContextListenerTest extends TestCase ->method('getSession') ->willReturn($session); - $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST, new Response()); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, new Response()); $dispatcher->expects($this->once()) ->method('removeListener') @@ -334,7 +334,7 @@ class ContextListenerTest extends TestCase }); $listener = new ContextListener($tokenStorage, [new NotSupportingUserProvider(true), new NotSupportingUserProvider(false), new SupportingUserProvider($refreshedUser)], 'context_key', null, $eventDispatcher); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); $this->assertNull($tokenStorage->getToken()); } @@ -351,7 +351,7 @@ class ContextListenerTest extends TestCase $tokenStorage = new TokenStorage(); $listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, [$tokenStorage, 'getToken']); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); $this->assertSame($usageIndex, $session->getUsageIndex()); } @@ -370,7 +370,7 @@ class ContextListenerTest extends TestCase $tokenStorage = new TokenStorage(); $listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, [$tokenStorage, 'getToken']); - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); } protected function runSessionOnKernelResponse($newToken, $original = null) @@ -402,7 +402,7 @@ class ContextListenerTest extends TestCase $event = new ResponseEvent( $this->createMock(HttpKernelInterface::class), $request, - HttpKernelInterface::MASTER_REQUEST, + HttpKernelInterface::MAIN_REQUEST, new Response() ); @@ -452,7 +452,7 @@ class ContextListenerTest extends TestCase if ($rememberMeServices) { $listener->setRememberMeServices($rememberMeServices); } - $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); + $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)); if (null !== $user) { ++$usageIndex; diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 3c6020b27d..d92a070e87 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -203,7 +203,7 @@ class ExceptionListenerTest extends TestCase $kernel = $this->createMock(HttpKernelInterface::class); } - return new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception); + return new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, $exception); } private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 2ae8abc230..6f374edd26 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -352,7 +352,7 @@ class RememberMeListenerTest extends TestCase $request = $request ?? new Request(); $event = $this->getMockBuilder(RequestEvent::class) - ->setConstructorArgs([$this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST]) + ->setConstructorArgs([$this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST]) ->getMock(); $event ->expects($this->any()) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 987d556a07..f5d808d6db 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -53,7 +53,7 @@ class SwitchUserListenerTest extends TestCase $this->userChecker = $this->createMock(UserCheckerInterface::class); $this->accessDecisionManager = $this->createMock(AccessDecisionManagerInterface::class); $this->request = new Request(); - $this->event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->request, HttpKernelInterface::MASTER_REQUEST); + $this->event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->request, HttpKernelInterface::MAIN_REQUEST); } public function testFirewallNameIsRequired() diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index dc4a3de8f3..0244c6582a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -107,7 +107,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase new DefaultAuthenticationFailureHandler($this->createMock(HttpKernelInterface::class), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener($event); } @@ -130,7 +130,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase new DefaultAuthenticationFailureHandler($this->createMock(HttpKernelInterface::class), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener($event); } @@ -153,7 +153,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase new DefaultAuthenticationFailureHandler($this->createMock(HttpKernelInterface::class), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener($event); } @@ -180,7 +180,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase new DefaultAuthenticationFailureHandler($this->createMock(HttpKernelInterface::class), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener($event); } @@ -204,7 +204,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase new DefaultAuthenticationFailureHandler($this->createMock(HttpKernelInterface::class), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener($event); } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index 0a2e6e991a..59e241318c 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -77,7 +77,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertEquals('ok', $event->getResponse()->getContent()); @@ -88,7 +88,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->createListener(); $request = new Request([], [], [], [], [], [], '{"username": "dunglas", "password": "foo"}'); $request->setRequestFormat('json-ld'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertEquals('ok', $event->getResponse()->getContent()); @@ -98,7 +98,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener([], false, true, false); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertSame(['error' => 'An authentication exception occurred.'], json_decode($event->getResponse()->getContent(), true)); @@ -114,7 +114,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->listener->setTranslator($translator); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertSame(['error' => 'foo'], json_decode($event->getResponse()->getContent(), true)); @@ -124,7 +124,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener(['username_path' => 'user.login', 'password_path' => 'user.pwd']); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"user": {"login": "dunglas", "pwd": "foo"}}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertEquals('ok', $event->getResponse()->getContent()); @@ -137,7 +137,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->createListener(); $request = new Request(); $request->setRequestFormat('json'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); } @@ -148,7 +148,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->expectExceptionMessage('The key "username" must be provided'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"usr": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); } @@ -159,7 +159,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->expectExceptionMessage('The key "password" must be provided'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "pass": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); } @@ -170,7 +170,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->expectExceptionMessage('The key "username" must be a string.'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": 1, "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); } @@ -181,7 +181,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->expectExceptionMessage('The key "password" must be a string.'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": 1}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); } @@ -191,7 +191,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->createListener(); $username = str_repeat('x', Security::MAX_USERNAME_LENGTH + 1); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], sprintf('{"username": "%s", "password": 1}', $username)); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertSame('ko', $event->getResponse()->getContent()); @@ -201,7 +201,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener(['check_path' => '/'], true, false); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json']); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); $event->setResponse(new Response('original')); ($this->listener)($event); @@ -212,7 +212,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener(); $request = new Request([], [], [], [], [], [], '{"username": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); $event->setResponse(new Response('original')); ($this->listener)($event); @@ -223,7 +223,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase { $this->createListener(['check_path' => '/']); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertSame('ok', $event->getResponse()->getContent()); @@ -234,7 +234,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); $this->configurePreviousSession($request); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); ($this->listener)($event); $this->assertEquals('ok', $event->getResponse()->getContent()); @@ -245,7 +245,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": "foo"}'); $this->configurePreviousSession($request); - $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(KernelInterface::class), $request, KernelInterface::MAIN_REQUEST); $sessionStrategy = $this->createMock(SessionAuthenticationStrategyInterface::class); $sessionStrategy->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index f607aa3857..9a323003eb 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -43,7 +43,7 @@ class FirewallTest extends TestCase ->willReturn([[], $listener, null]) ; - $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $firewall = new Firewall($map, $dispatcher); $firewall->onKernelRequest($event); @@ -73,7 +73,7 @@ class FirewallTest extends TestCase ->setConstructorArgs([ $this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), - HttpKernelInterface::MASTER_REQUEST, + HttpKernelInterface::MAIN_REQUEST, ]) ->getMock() ; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 78dfd57474..75b3e31a6a 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -89,7 +89,7 @@ class ResponseListenerTest extends TestCase return $response; } - private function getEvent(Request $request, Response $response, int $type = HttpKernelInterface::MASTER_REQUEST): ResponseEvent + private function getEvent(Request $request, Response $response, int $type = HttpKernelInterface::MAIN_REQUEST): ResponseEvent { return new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, $type, $response); } diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index d953ac23a6..ff60e9bf89 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1", "symfony/security-core": "^5.3", - "symfony/http-foundation": "^5.2", + "symfony/http-foundation": "^5.3", "symfony/http-kernel": "^5.3", "symfony/polyfill-php80": "^1.15", "symfony/property-access": "^4.4|^5.0" diff --git a/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php b/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php index 25faf15beb..fd89db17e3 100644 --- a/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php +++ b/src/Symfony/Component/WebLink/EventListener/AddLinkHeaderListener.php @@ -38,7 +38,7 @@ class AddLinkHeaderListener implements EventSubscriberInterface public function onKernelResponse(ResponseEvent $event) { - if (!$event->isMasterRequest()) { + if (!$event->isMainRequest()) { return; } diff --git a/src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php b/src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php index b43d7f68b1..dc807d1ab4 100644 --- a/src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php +++ b/src/Symfony/Component/WebLink/Tests/EventListener/AddLinkHeaderListenerTest.php @@ -34,7 +34,7 @@ class AddLinkHeaderListenerTest extends TestCase $subscriber = new AddLinkHeaderListener(); - $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, $response); $subscriber->onKernelResponse($event); diff --git a/src/Symfony/Component/WebLink/composer.json b/src/Symfony/Component/WebLink/composer.json index a3a729f1ef..ba094a8d5c 100644 --- a/src/Symfony/Component/WebLink/composer.json +++ b/src/Symfony/Component/WebLink/composer.json @@ -27,10 +27,10 @@ }, "require-dev": { "symfony/http-foundation": "^4.4|^5.0", - "symfony/http-kernel": "^4.4|^5.0" + "symfony/http-kernel": "^5.3" }, "conflict": { - "symfony/http-kernel": "<4.4" + "symfony/http-kernel": "<5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\WebLink\\": "" },