Skip to content

Commit be17eaf

Browse files
jakzalfabpot
authored andcommitted
Do not call the FragmentListener if _controller is already defined
1 parent 2e7f181 commit be17eaf

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function onKernelRequest(GetResponseEvent $event)
5757
{
5858
$request = $event->getRequest();
5959

60-
if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) {
60+
if ($request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo())) {
6161
return;
6262
}
6363

src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ public function testOnlyTriggeredOnFragmentRoute()
3434
$this->assertTrue($request->query->has('_path'));
3535
}
3636

37+
38+
public function testOnlyTriggeredIfControllerWasNotDefinedYet()
39+
{
40+
$request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo');
41+
$request->attributes->set('_controller', 'bar');
42+
43+
$listener = new FragmentListener(new UriSigner('foo'));
44+
$event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST);
45+
46+
$expected = $request->attributes->all();
47+
48+
$listener->onKernelRequest($event);
49+
50+
$this->assertEquals($expected, $request->attributes->all());
51+
}
52+
3753
/**
3854
* @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
3955
*/
@@ -74,8 +90,8 @@ public function testWithSignature()
7490
$this->assertFalse($request->query->has('_path'));
7591
}
7692

77-
private function createGetResponseEvent(Request $request)
93+
private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST)
7894
{
79-
return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST);
95+
return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType);
8096
}
8197
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy