From 05ee088911aad0a4f3307b28046190b962027bcd Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 1 Dec 2021 18:13:00 +0100 Subject: [PATCH] Fix using FileLinkFormatter after serialization --- .../Component/HttpKernel/Debug/FileLinkFormatter.php | 4 ++-- .../HttpKernel/Tests/Debug/FileLinkFormatterTest.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 2879273005428..fc85efce4ae00 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -35,8 +35,8 @@ class FileLinkFormatter ]; private array|false $fileLinkFormat; - private ?RequestStack $requestStack; - private ?string $baseDir; + private ?RequestStack $requestStack = null; + private ?string $baseDir = null; private \Closure|string|null $urlFormat; /** diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php index 548112ad52fef..35a4e1658eb48 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php @@ -25,6 +25,13 @@ public function testWhenNoFileLinkFormatAndNoRequest() $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); } + public function testAfterUnserialize() + { + $sut = unserialize(serialize(new FileLinkFormatter())); + + $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); + } + public function testWhenFileLinkFormatAndNoRequest() { $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';