Skip to content

Commit d026426

Browse files
committed
Rename master request to main request
1 parent bb4e5fd commit d026426

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+235
-216
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ CHANGELOG
99
* Deprecate `ArgumentMetadata::getAttribute()`, use `getAttributes()` instead
1010
* Mark the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal
1111
* Deprecate returning a `ContainerBuilder` from `KernelInterface::registerContainerConfiguration()`
12+
* Deprecate `HttpKernelInterface::MASTER_REQUEST` and add `HttpKernelInterface::MAIN_REQUEST` as replacement
13+
* Deprecate `KernelEvent::isMasterRequest()` and add `isMainRequest()` as replacement
1214

1315
5.2.0
1416
-----

DataCollector/DumpDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function collect(Request $request, Response $response, \Throwable $except
107107
}
108108

109109
// Sub-requests and programmatic calls stay in the collected profile.
110-
if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
110+
if ($this->dumper || ($this->requestStack && $this->requestStack->getMainRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
111111
return;
112112
}
113113

DataCollector/EventDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null, Request
4242
*/
4343
public function collect(Request $request, Response $response, \Throwable $exception = null)
4444
{
45-
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
45+
$this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null;
4646
$this->data = [
4747
'called_listeners' => [],
4848
'not_called_listeners' => [],

DataCollector/LoggerDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct($logger = null, string $containerPathPrefix = null,
4646
*/
4747
public function collect(Request $request, Response $response, \Throwable $exception = null)
4848
{
49-
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
49+
$this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null;
5050
}
5151

5252
/**

DataCollector/RequestDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function collect(Request $request, Response $response, \Throwable $except
106106
'session_metadata' => $sessionMetadata,
107107
'session_attributes' => $sessionAttributes,
108108
'session_usages' => array_values($this->sessionUsages),
109-
'stateless_check' => $this->requestStack && $this->requestStack->getMasterRequest()->attributes->get('_stateless', false),
109+
'stateless_check' => $this->requestStack && $this->requestStack->getMainRequest()->attributes->get('_stateless', false),
110110
'flashes' => $flashes,
111111
'path_info' => $request->getPathInfo(),
112112
'controller' => 'n/a',
@@ -374,7 +374,7 @@ public function onKernelController(ControllerEvent $event)
374374

375375
public function onKernelResponse(ResponseEvent $event)
376376
{
377-
if (!$event->isMasterRequest()) {
377+
if (!$event->isMainRequest()) {
378378
return;
379379
}
380380

Debug/FileLinkFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private function getFileLinkFormat()
9191
}
9292

9393
if ($this->requestStack && $this->baseDir && $this->urlFormat) {
94-
$request = $this->requestStack->getMasterRequest();
94+
$request = $this->requestStack->getMainRequest();
9595

9696
if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
9797
return [

Event/KernelEvent.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class KernelEvent extends Event
2828

2929
/**
3030
* @param int $requestType The request type the kernel is currently processing; one of
31-
* HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST
31+
* HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST
3232
*/
3333
public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType)
3434
{
@@ -60,21 +60,33 @@ public function getRequest()
6060
/**
6161
* Returns the request type the kernel is currently processing.
6262
*
63-
* @return int One of HttpKernelInterface::MASTER_REQUEST and
63+
* @return int One of HttpKernelInterface::MAIN_REQUEST and
6464
* HttpKernelInterface::SUB_REQUEST
6565
*/
6666
public function getRequestType()
6767
{
6868
return $this->requestType;
6969
}
7070

71+
/**
72+
* Checks if this is the main request.
73+
*/
74+
public function isMainRequest(): bool
75+
{
76+
return HttpKernelInterface::MAIN_REQUEST === $this->requestType;
77+
}
78+
7179
/**
7280
* Checks if this is a master request.
7381
*
7482
* @return bool True if the request is a master request
83+
*
84+
* @deprecated since symfony/http-kernel 5.3, use isMainRequest() instead
7585
*/
7686
public function isMasterRequest()
7787
{
78-
return HttpKernelInterface::MASTER_REQUEST === $this->requestType;
88+
trigger_deprecation('symfony/http-kernel', '5.3', '"%s()" is deprecated, use "isMainRequest()" instead.');
89+
90+
return $this->isMainRequest();
7991
}
8092
}

Event/TerminateEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
/**
1919
* Allows to execute logic after a response was sent.
2020
*
21-
* Since it's only triggered on master requests, the `getRequestType()` method
22-
* will always return the value of `HttpKernelInterface::MASTER_REQUEST`.
21+
* Since it's only triggered on main requests, the `getRequestType()` method
22+
* will always return the value of `HttpKernelInterface::MAIN_REQUEST`.
2323
*
2424
* @author Jordi Boggiano <j.boggiano@seld.be>
2525
*/
@@ -29,7 +29,7 @@ final class TerminateEvent extends KernelEvent
2929

3030
public function __construct(HttpKernelInterface $kernel, Request $request, Response $response)
3131
{
32-
parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
32+
parent::__construct($kernel, $request, HttpKernelInterface::MAIN_REQUEST);
3333

3434
$this->response = $response;
3535
}

EventListener/AbstractSessionListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(ContainerInterface $container = null, bool $debug =
5252

5353
public function onKernelRequest(RequestEvent $event)
5454
{
55-
if (!$event->isMasterRequest()) {
55+
if (!$event->isMainRequest()) {
5656
return;
5757
}
5858

@@ -69,7 +69,7 @@ public function onKernelRequest(RequestEvent $event)
6969

7070
public function onKernelResponse(ResponseEvent $event)
7171
{
72-
if (!$event->isMasterRequest()) {
72+
if (!$event->isMainRequest()) {
7373
return;
7474
}
7575

@@ -138,7 +138,7 @@ public function onKernelResponse(ResponseEvent $event)
138138

139139
public function onFinishRequest(FinishRequestEvent $event)
140140
{
141-
if ($event->isMasterRequest()) {
141+
if ($event->isMainRequest()) {
142142
array_pop($this->sessionUsageStack);
143143
}
144144
}

EventListener/AbstractTestSessionListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(array $sessionOptions = [])
4141

4242
public function onKernelRequest(RequestEvent $event)
4343
{
44-
if (!$event->isMasterRequest()) {
44+
if (!$event->isMainRequest()) {
4545
return;
4646
}
4747

@@ -59,12 +59,12 @@ public function onKernelRequest(RequestEvent $event)
5959
}
6060

6161
/**
62-
* Checks if session was initialized and saves if current request is master
62+
* Checks if session was initialized and saves if current request is the main request
6363
* Runs on 'kernel.response' in test environment.
6464
*/
6565
public function onKernelResponse(ResponseEvent $event)
6666
{
67-
if (!$event->isMasterRequest()) {
67+
if (!$event->isMainRequest()) {
6868
return;
6969
}
7070

0 commit comments

Comments
 (0)