Skip to content

Commit bec6161

Browse files
Merge branch '5.4' into 6.0
* 5.4: [HttpKernel] Fix test sensitivity on xdebug.file_link_format [HttpKernel] Fix non-scalar check in surrogate fragment renderer [Debug][ErrorHandler] fix operator precedence [Cache] Ensured that redis adapter can use multiple redis sentinel hosts [DoctrineBridge] fix tests [Security] Allow redirect after login to absolute URLs
2 parents 93ee055 + 141427d commit bec6161

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
4545

4646
public function __construct(Stopwatch $stopwatch = null, string|FileLinkFormatter $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, DataDumperInterface|Connection $dumper = null)
4747
{
48+
$fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
4849
$this->stopwatch = $stopwatch;
49-
$this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
50+
$this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter && false === $fileLinkFormat->format('', 0) ? false : $fileLinkFormat;
5051
$this->charset = $charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8';
5152
$this->requestStack = $requestStack;
5253
$this->dumper = $dumper;

Debug/FileLinkFormatter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ class FileLinkFormatter
4242
/**
4343
* @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
4444
*/
45-
public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
45+
public function __construct(string|array $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
4646
{
47-
$fileLinkFormat = (self::FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false;
48-
if ($fileLinkFormat && !\is_array($fileLinkFormat)) {
47+
if (!\is_array($fileLinkFormat) && $fileLinkFormat = (self::FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false) {
4948
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
5049
$fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);
5150
}

Fragment/AbstractSurrogateFragmentRenderer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ private function generateSignedFragmentUri(ControllerReference $uri, Request $re
8989
private function containsNonScalars(array $values): bool
9090
{
9191
foreach ($values as $value) {
92-
if (\is_array($value)) {
93-
return $this->containsNonScalars($value);
94-
} elseif (!\is_scalar($value) && null !== $value) {
92+
if (\is_scalar($value) || null === $value) {
93+
continue;
94+
}
95+
96+
if (!\is_array($value) || $this->containsNonScalars($value)) {
9597
return true;
9698
}
9799
}

Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
18+
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
1819
use Symfony\Component\VarDumper\Cloner\Data;
1920
use Symfony\Component\VarDumper\Dumper\CliDumper;
2021
use Symfony\Component\VarDumper\Server\Connection;
@@ -28,7 +29,7 @@ public function testDump()
2829
{
2930
$data = new Data([[123]]);
3031

31-
$collector = new DumpDataCollector();
32+
$collector = new DumpDataCollector(null, new FileLinkFormatter([]));
3233

3334
$this->assertSame('dump', $collector->getName());
3435

Tests/Debug/FileLinkFormatterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FileLinkFormatterTest extends TestCase
2020
{
2121
public function testWhenNoFileLinkFormatAndNoRequest()
2222
{
23-
$sut = new FileLinkFormatter();
23+
$sut = new FileLinkFormatter([]);
2424

2525
$this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3));
2626
}
@@ -54,7 +54,7 @@ public function testWhenNoFileLinkFormatAndRequest()
5454
$request->server->set('SCRIPT_FILENAME', '/public/index.php');
5555
$request->server->set('REQUEST_URI', '/index.php/example');
5656

57-
$sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
57+
$sut = new FileLinkFormatter([], $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
5858

5959
$this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
6060
}

0 commit comments

Comments
 (0)