Skip to content

Commit 70b12a8

Browse files
committed
bug #18562 [2.7][WebProfilerBunde] Give an absolute url in case the request occured from another domain (romainneutron)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7][WebProfilerBunde] Give an absolute url in case the request occured from another domain | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This is related to #18413: Using two symfony application ProjectA and MicroServiceB, if ProjectA issues XHR to MicroServiceB and both have the WebProfilerBundle enabled, then Ajax requests will be monitored in ProjectA. But - at the moment - it will try to look for profiles under ProjectA domain whereas data are stored on MicroServiceB domain. This PR fixes this issue Commits ------- 1a5d4ad [WebProfilerBunde] Give an absolute url in case the request occured from another domain
2 parents 1ff12d9 + 1a5d4ad commit 70b12a8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function onKernelResponse(FilterResponseEvent $event)
6565
try {
6666
$response->headers->set(
6767
'X-Debug-Token-Link',
68-
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')))
68+
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')), UrlGeneratorInterface::ABSOLUTE_URL)
6969
);
7070
} catch (\Exception $e) {
7171
$response->headers->set('X-Debug-Error', get_class($e).': '.$e->getMessage());

src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1818
use Symfony\Component\HttpKernel\HttpKernelInterface;
19+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920

2021
class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
2122
{
@@ -195,16 +196,16 @@ public function testXDebugUrlHeader()
195196
$urlGenerator
196197
->expects($this->once())
197198
->method('generate')
198-
->with('_profiler', array('token' => 'xxxxxxxx'))
199-
->will($this->returnValue('/_profiler/xxxxxxxx'))
199+
->with('_profiler', array('token' => 'xxxxxxxx'), UrlGeneratorInterface::ABSOLUTE_URL)
200+
->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx'))
200201
;
201202

202203
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
203204

204205
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
205206
$listener->onKernelResponse($event);
206207

207-
$this->assertEquals('/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
208+
$this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
208209
}
209210

210211
public function testThrowingUrlGenerator()

0 commit comments

Comments
 (0)