Skip to content

Commit c92cfe6

Browse files
committed
Fix handling ESI request
1 parent 02a05a0 commit c92cfe6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/EventListener/RequestListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ public function onKernelController(FilterControllerEvent $event): void
8888
return;
8989
}
9090

91+
if (! $event->getRequest()->attributes->has('_route')) {
92+
return;
93+
}
94+
9195
$matchedRoute = $event->getRequest()->attributes->get('_route');
9296

9397
Hub::getCurrent()

test/EventListener/RequestListenerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,28 @@ public function testOnKernelControllerAddsRouteTag(): void
355355
$this->assertSame(['route' => 'sf-route'], $this->currentScope->getTags());
356356
}
357357

358+
public function testOnKernelControllerRouteTagIsNotSetIfRequestDoesNotHaveARoute(): void
359+
{
360+
$this->currentHub->configureScope(Argument::type('callable'))
361+
->shouldNotBeCalled();
362+
363+
$request = new Request();
364+
$event = $this->prophesize(FilterControllerEvent::class);
365+
366+
$event->isMasterRequest()
367+
->willReturn(true);
368+
$event->getRequest()
369+
->willReturn($request);
370+
371+
$listener = new RequestListener(
372+
$this->currentHub->reveal(),
373+
$this->prophesize(TokenStorageInterface::class)->reveal(),
374+
$this->prophesize(AuthorizationCheckerInterface::class)->reveal()
375+
);
376+
377+
$listener->onKernelController($event->reveal());
378+
}
379+
358380
public function testOnKernelRequestUserDataAndTagsAreNotSetInSubRequest(): void
359381
{
360382
$this->currentHub->configureScope(Argument::type('callable'))

0 commit comments

Comments
 (0)