Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Typed property Symfony\Bridge\Monolog\Handler\ChromePhpHandler::$response must not be accessed before initialization #44513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Philipp91 opened this issue Dec 8, 2021 · 2 comments

Comments

@Philipp91
Copy link
Contributor

Philipp91 commented Dec 8, 2021

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.

@derrabus

Additional Context

No response

@chalasr
Copy link
Member

chalasr commented Dec 8, 2021

Would you mind sending a PR changing that statement to if ($this->response ?? false) { on the 6.0 branch?

@Philipp91
Copy link
Contributor Author

Is that better than isset()?

fancyweb added a commit that referenced this issue Dec 9, 2021
…::$response (Philipp91)

This PR was merged into the 6.0 branch.

Discussion
----------

Don't access uninitialized typed property ChromePhpHandler::$response

Fixes #44513

| Q             | A
| ------------- | ---
| Branch?       | 6.0
| Bug fix?      | yes
| Tickets       | Fix #44513
| License       | MIT

Commits
-------

da457d9 Don't access uninitialized typed property ChromePhpHandler::$response
@fancyweb fancyweb closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants