From fb72bc54f300151fadef84fce79764138b1ef943 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 30 Sep 2022 09:27:59 +0200 Subject: [PATCH 01/13] Update VERSION for 4.4.46 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 09c0f68162..c6476b615d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.46-DEV'; + public const VERSION = '4.4.46'; public const VERSION_ID = 40446; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 46; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 253b181271d9345963ba02185362b7cbe6527637 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 30 Sep 2022 09:39:45 +0200 Subject: [PATCH 02/13] Bump Symfony version to 4.4.47 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index c6476b615d..8133c320cd 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.46'; - public const VERSION_ID = 40446; + public const VERSION = '4.4.47-DEV'; + public const VERSION_ID = 40447; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 46; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 47; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 91cf5dbc9ea4d902470e596246a736179acfb79d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:05:45 +0200 Subject: [PATCH 03/13] Update VERSION for 4.4.47 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8133c320cd..f944b3d9e6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.47-DEV'; + public const VERSION = '4.4.47'; public const VERSION_ID = 40447; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 47; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From d84ce93ce38b50926cb14416fbdeea88ab8e5729 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:11:51 +0200 Subject: [PATCH 04/13] Bump Symfony version to 4.4.48 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f944b3d9e6..13636cc09f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.47'; - public const VERSION_ID = 40447; + public const VERSION = '4.4.48-DEV'; + public const VERSION_ID = 40448; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 47; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 48; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 6f77fabc1a37c2dceecc6f78cca44772705dc52f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:12:21 +0200 Subject: [PATCH 05/13] Update VERSION for 5.4.14 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6e20f90721..25370cef3f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.14-DEV'; + public const VERSION = '5.4.14'; public const VERSION_ID = 50414; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 14; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 28fbba690fc2be08c966715b9e04fdc83ab67e4a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:43:05 +0200 Subject: [PATCH 06/13] Bump Symfony version to 5.4.15 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 25370cef3f..700f16d3ce 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.14'; - public const VERSION_ID = 50414; + public const VERSION = '5.4.15-DEV'; + public const VERSION_ID = 50415; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 14; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 15; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From f9fc93c4f12e2fd7dea37f7b5840deb34e9037fc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:43:45 +0200 Subject: [PATCH 07/13] Update VERSION for 6.0.14 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 29da5629cf..ff528028c0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.14-DEV'; + public const VERSION = '6.0.14'; public const VERSION_ID = 60014; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; public const RELEASE_VERSION = 14; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From e5a23b5e88a2a21cc9f82d149ab57705243a958f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:48:13 +0200 Subject: [PATCH 08/13] Bump Symfony version to 6.0.15 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ff528028c0..111cefd0f2 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.14'; - public const VERSION_ID = 60014; + public const VERSION = '6.0.15-DEV'; + public const VERSION_ID = 60015; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; - public const RELEASE_VERSION = 14; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 15; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From 97759f4370311c3b2a0172750df09db96309d3f0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 Oct 2022 09:54:12 +0200 Subject: [PATCH 09/13] Bump Symfony version to 6.1.7 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3c8c4068dc..fa83f540d9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.6'; - public const VERSION_ID = 60106; + public const VERSION = '6.1.7-DEV'; + public const VERSION_ID = 60107; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; - public const RELEASE_VERSION = 6; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 7; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023'; From abc13578a29babe39da78eb78923f49d29286305 Mon Sep 17 00:00:00 2001 From: cyve Date: Sun, 16 Oct 2022 18:02:26 +0200 Subject: [PATCH 10/13] [HttpKernel] Remove EOL when using error_log() in HttpKernel Logger --- Log/Logger.php | 18 +++++++++++------- Tests/Log/LoggerTest.php | 24 ++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Log/Logger.php b/Log/Logger.php index 3e1db33466..1238517f64 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -44,10 +44,14 @@ public function __construct(string $minLevel = null, $output = null, callable $f if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) { - case -1: $minLevel = LogLevel::ERROR; break; - case 1: $minLevel = LogLevel::NOTICE; break; - case 2: $minLevel = LogLevel::INFO; break; - case 3: $minLevel = LogLevel::DEBUG; break; + case -1: $minLevel = LogLevel::ERROR; + break; + case 1: $minLevel = LogLevel::NOTICE; + break; + case 2: $minLevel = LogLevel::INFO; + break; + case 3: $minLevel = LogLevel::DEBUG; + break; } } } @@ -80,7 +84,7 @@ public function log($level, $message, array $context = []) $formatter = $this->formatter; if ($this->handle) { - @fwrite($this->handle, $formatter($level, $message, $context)); + @fwrite($this->handle, $formatter($level, $message, $context).\PHP_EOL); } else { error_log($formatter($level, $message, $context, false)); } @@ -91,7 +95,7 @@ private function format(string $level, string $message, array $context, bool $pr if (str_contains($message, '{')) { $replacements = []; foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { + if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); @@ -105,7 +109,7 @@ private function format(string $level, string $message, array $context, bool $pr $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message).\PHP_EOL; + $log = sprintf('[%s] %s', $level, $message); if ($prefixDate) { $log = date(\DateTime::RFC3339).' '.$log; } diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index fb2b43cc82..5996e6e72a 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -48,7 +48,7 @@ protected function tearDown(): void public static function assertLogsMatch(array $expected, array $given) { foreach ($given as $k => $line) { - self::assertThat(1 === preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[\+-][0-9]{2}:[0-9]{2} '.preg_quote($expected[$k]).'/', $line), self::isTrue(), "\"$line\" do not match expected pattern \"$expected[$k]\""); + self::assertSame(1, preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[\+-][0-9]{2}:[0-9]{2} '.preg_quote($expected[$k]).'/', $line), "\"$line\" do not match expected pattern \"$expected[$k]\""); } } @@ -186,7 +186,7 @@ public function testContextExceptionKeyCanBeExceptionOrOtherValues() public function testFormatter() { $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).\PHP_EOL; + return json_encode(['level' => $level, 'message' => $message, 'context' => $context]); }); $this->logger->error('An error', ['foo' => 'bar']); @@ -196,6 +196,26 @@ public function testFormatter() '{"level":"warning","message":"A warning","context":{"baz":"bar"}}', ], $this->getLogs()); } + + public function testLogsWithoutOutput() + { + $oldErrorLog = ini_set('error_log', $this->tmpFile); + + $logger = new Logger(); + $logger->error('test'); + $logger->critical('test'); + + $expected = [ + '[error] test', + '[critical] test', + ]; + + foreach ($this->getLogs() as $k => $line) { + $this->assertSame(1, preg_match('/\[[\w\/\-: ]+\] '.preg_quote($expected[$k]).'/', $line), "\"$line\" do not match expected pattern \"$expected[$k]\""); + } + + ini_set('error_log', $oldErrorLog); + } } class DummyTest From 3f611709a785bebe25aa124a22b46747e38e0b21 Mon Sep 17 00:00:00 2001 From: Krzysztof Pyrkosz Date: Thu, 13 Oct 2022 17:34:04 +0200 Subject: [PATCH 11/13] [HttpKernel] Fix empty request stack when terminating with exception --- HttpKernel.php | 12 +++++++++++- Tests/HttpKernelTest.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/HttpKernel.php b/HttpKernel.php index d53b80665b..e23023d3c4 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -112,7 +112,17 @@ public function terminateWithException(\Throwable $exception, Request $request = throw $exception; } - $response = $this->handleThrowable($exception, $request, self::MASTER_REQUEST); + if ($pop = $request !== $this->requestStack->getMasterRequest()) { + $this->requestStack->push($request); + } + + try { + $response = $this->handleThrowable($exception, $request, self::MASTER_REQUEST); + } finally { + if ($pop) { + $this->requestStack->pop(); + } + } $response->sendHeaders(); $response->sendContent(); diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 53e5f547d2..a163715f81 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -20,6 +20,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; +use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException; @@ -340,6 +341,22 @@ public function testTerminate() $this->assertEquals($response, $capturedResponse); } + public function testTerminateWithException() + { + $dispatcher = new EventDispatcher(); + $requestStack = new RequestStack(); + $kernel = $this->getHttpKernel($dispatcher, null, $requestStack); + + $dispatcher->addListener(KernelEvents::EXCEPTION, function (ExceptionEvent $event) use (&$capturedRequest, $requestStack) { + $capturedRequest = $requestStack->getCurrentRequest(); + $event->setResponse(new Response()); + }); + + $kernel->terminateWithException(new \Exception('boo'), $request = Request::create('/')); + $this->assertSame($request, $capturedRequest); + $this->assertNull($requestStack->getCurrentRequest()); + } + public function testVerifyRequestStackPushPopDuringHandle() { $request = new Request(); From 7dc3aac73bc0fbccdc69f3f5d68adaf17a344f2d Mon Sep 17 00:00:00 2001 From: "Phil E. Taylor" Date: Thu, 27 Oct 2022 08:55:40 +0100 Subject: [PATCH 12/13] Typos In Comments --- Tests/HttpCache/HttpCacheTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index cef30fad05..7d8ef79187 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -590,7 +590,7 @@ public function testDegradationWhenCacheLocked() $this->cacheConfig['stale_while_revalidate'] = 10; - // The prescence of Last-Modified makes this cacheable (because Response::isValidateable() then). + // The presence of Last-Modified makes this cacheable (because Response::isValidateable() then). $this->setNextResponse(200, ['Cache-Control' => 'public, s-maxage=5', 'Last-Modified' => 'some while ago'], 'Old response'); $this->request('GET', '/'); // warm the cache From 8fc1ffe753948c47a103a809cdd6a4a8458b3254 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 28 Oct 2022 20:06:36 +0200 Subject: [PATCH 13/13] Update VERSION for 6.1.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index fa83f540d9..78193d31c6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.1.7-DEV'; + public const VERSION = '6.1.7'; public const VERSION_ID = 60107; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 1; public const RELEASE_VERSION = 7; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2023'; public const END_OF_LIFE = '01/2023';