8000 bug #28183 [WebProfilerBundle] fix wrong url when base path is the in… · symfony/symfony@edbd869 · GitHub
[go: up one dir, main page]

Skip to content

Commit edbd869

Browse files
committed
bug #28183 [WebProfilerBundle] fix wrong url when base path is the index (ismail1432)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #28183). Discussion ---------- [WebProfilerBundle] fix wrong url when base path is the index | Q | A | ------------- | --- | Branch? | >= 3.4 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27846 <!-- #-prefixed issue number(s), if any --> | License | MIT The `FileLinkFormatter` create a wrong url because it's using [getBaseUrl](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L870) that render the script filename, the problem is that in this class it's used twice, first time with the [getBaseUrl method](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php#L99) and another time with the [generate method](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php#L77). Just switch to `getBasePath` solve the issue. WDYT ? Commits ------- 897615e change baseUrl to basePath to fix wrong profiler url
2 parents 9a97ea8 + 897615e commit edbd869

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function getFileLinkFormat()
100100
}
101101

102102
return array(
103-
$request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat,
103+
$request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
104104
$this->baseDir.\DIRECTORY_SEPARATOR, '',
105105
);
106106
}

src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function testWhenFileLinkFormatAndNoRequest()
3737
public function testWhenFileLinkFormatAndRequest()
3838
{
3939
$file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
40-
$baseDir = __DIR__;
4140
$requestStack = new RequestStack();
4241
$request = new Request();
4342
$requestStack->push($request);
@@ -56,12 +55,12 @@ public function testWhenNoFileLinkFormatAndRequest()
5655

5756
$request->server->set('SERVER_NAME', 'www.example.org');
5857
$request->server->set('SERVER_PORT', 80);
59-
$request->server->set('SCRIPT_NAME', '/app.php');
60-
$request->server->set('SCRIPT_FILENAME', '/web/app.php');
61-
$request->server->set('REQUEST_URI', '/app.php/example');
58+
$request->server->set('SCRIPT_NAME', '/index.php');
59+
$request->server->set('SCRIPT_FILENAME', '/public/index.php');
60+
$request->server->set('REQUEST_URI', '/index.php/example');
6261

6362
$sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
6463

65-
$this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
64+
$this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
6665
}
6766
}

0 commit comments

Comments
 (0)
0