Closed
Description
Symfony version(s) affected
6.0.0
Description
I'm in the process of upgrading to Symfony v6. When I want to access any page (from Chrome), I get this:
[2021-12-08T20:01:26.600149+00:00] php.CRITICAL: Uncaught Error: Typed property Symfony\Bridge\Monolog\Handler\ChromePhpHandler::$response must not be accessed before initialization {"exception":"[object] (Error(code: 0): Typed property Symfony\\Bridge\\Monolog\\Handler\\ChromePhpHandler::$response must not be accessed before initialization at $ROOTDIR/vendor/symfony/monolog-bridge/Handler/ChromePhpHandler.php:62)
[stacktrace]
#0 $ROOTDIR/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php(168): Symfony\\Bridge\\Monolog\\Handler\\ChromePhpHandler->sendHeader()
#1 $ROOTDIR/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php(123): Monolog\\Handler\\ChromePHPHandler->send()
#2 $ROOTDIR/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): Monolog\\Handler\\ChromePHPHandler->write()
#3 $ROOTDIR/vendor/monolog/monolog/src/Monolog/Logger.php(317): Monolog\\Handler\\AbstractProcessingHandler->handle()
#4 $ROOTDIR/vendor/monolog/monolog/src/Monolog/Logger.php(552): Monolog\\Logger->addRecord()
#5 $ROOTDIR/vendor/symfony/http-kernel/EventListener/ErrorListener.php(151): Monolog\\Logger->critical()
#6 $ROOTDIR/vendor/symfony/http-kernel/EventListener/ErrorListener.php(58): Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener->logException()
#7 $ROOTDIR/vendor/symfony/event-dispatcher/EventDispatcher.php(270): Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener->logKernelException()
#8 $ROOTDIR/vendor/symfony/event-dispatcher/EventDispatcher.php(230): Symfony\\Component\\EventDispatcher\\EventDispatcher::Symfony\\Component\\EventDispatcher\\{closure}()
#9 $ROOTDIR/vendor/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\\Component\\EventDispatcher\\EventDispatcher->callListeners()
#10 $ROOTDIR/vendor/symfony/http-kernel/HttpKernel.php(213): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch()
#11 $ROOTDIR/vendor/symfony/http-kernel/HttpKernel.php(106): Symfony\\Component\\HttpKernel\\HttpKernel->handleThrowable()
#12 $ROOTDIR/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php(125): Symfony\\Component\\HttpKernel\\HttpKernel->terminateWithException()
#13 $ROOTDIR/vendor/symfony/error-handler/ErrorHandler.php(541): Symfony\\Component\\HttpKernel\\EventListener\\DebugHandlersListener::Symfony\\Component\\HttpKernel\\EventListener\\{closure}()
#14 [internal function]: Symfony\\Component\\ErrorHandler\\ErrorHandler->handleException()
#15 {main}
"} []
Surely this is caused by some underlying error, but I can't see that one because the ChromePhpHandler fails.
How to reproduce
Can't say, presumably just run any app with the latest version, including ErrorHandler and ChromePhpHandler?
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
chromephp:
type: chromephp
level: info
...
sendHeader()
is called already when the RouteListener
wants to log its "Matched route ..." information. But I guess that's normal.
Possible Solution
It's probably caused by 39fb557. Typed properties don't coerce to false
in an if
statement, so this line now needs updating.
Additional Context
No response