Re: How to debug "Unknown: Headers already sent"?

From: Date: Thu, 06 Jan 2022 17:15:37 +0000
Subject: Re: How to debug "Unknown: Headers already sent"?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-327879@lists.php.net to get a copy of this message
How do I get off this mail list? > On Jan 6, 2022, at 12:13 PM, Jānis Elmeris <janis.elmeris@lv.lv> wrote: > > How can I try debugging the "Unknown: Headers already sent. You cannot change the session > module's ini settings at this time in Unknown on line 0" warning, when PHP is not giving > any more details except that it happened (no info on what's trying to send the headers or where > the output had started). > > This warning happens from time to time only. (In my case, it happens when I browse a > Woocommerce store. It has happened in the local dev environment when I click on a product, when I > click on adding product to the cart, when I click to checkout. But it happens rarely. Mostly, all > the requests are processed all right, no PHP warnings.) > > Almost everything that I found about "headers already sent" on the Internet, refers > to the cases when the PHP code is written in a way that outputs some content before sending the > headers, in which case the PHP gives a reference to the PHP code that's in some way related to > the error. But the "unknown" cases are different. > > I found that this error may be caused by repeatedly loading the same PHP extensions, or by some > PHP extension working incorrectly. For example, "zlib" extension has had such problem when > executing "ob_gzhandler". > > I looked at the PHP configuration and didn't see an extension being loaded more than once. > Regarding "ob_gzhandler", I found only one place in the Wordpress code using it, and added > a log there. Then I got a headers already sent warning message, but the "ob_gzhandler" had > not been used in that request. > > So, how could this warning be tracked down? Can I use XDebug somehow to do it? > > I'm using PHP 7.4 FPM. > > Regards, > Janis

« previous php.general (#327879) next »