I added an auto_prepend_file which outputs into the error log, and it looks like the error happens even before the auto-prepend file.
A different timezone (set quite early in the Wordpress script) of the "headers already sent" message and the error log messages I added in the WP code, already hinted at that.
Could some incorrect (not quite correct) Nginx configuration cause it? (In combination with the specific code, as on the same server but outside of Wordpress / Woocommerce directory, this problem does not happen.)
Regards,
Janis No: Jānis Elmeris <janis.elmeris@xxxxx>
Nosūtīts: piektdiena, 2022. gada 7. janvāris 14:13 Kam: AllenJB <php.lists@xxxxxxxxxxxxx>; php-general@xxxxxxxxxxxxx <php-general@xxxxxxxxxxxxx> Tēma: Re: How to debug "Unknown: Headers already sent"?
Thank you for the reply!
I added error_logs before all the ini_sets I could find. When I browsed the Woocommerce, I got the error three times in about 10 minutes. Looking at the error log, it seemed that one time the error occurred right before one specific ini_set call, but the two
other cases didn't have explicit ini_set calls in the code around the time the "Unknown: Headers already sent." error appeared. So, I guess that the first one was just a coincidence.
I'm somehow not too hopeful of finding the problem in the PHP code seeing as PHP engine itself does not know which PHP code file causes the problem. So, I suppose, the problem should be on some other level, shouldn't it?
I saw someone on the Internet mentioning XDebug as a way to debug something like this but gave no details. Would you have any idea on how to use XDebug for such cases?
Janis
No: AllenJB <php.lists@xxxxxxxxxxxxx>
Nosūtīts: ceturtdiena, 2022. gada 6. janvāris 21:28 Kam: php-general@xxxxxxxxxxxxx <php-general@xxxxxxxxxxxxx> Tēma: Re: How to debug "Unknown: Headers already sent"?
On 06/01/2022 17:13, Jānis Elmeris wrote:
The error message is specifically complaining about ini settings being set. I would check the code for any calls to ini_set(), specifically that are modifying ini settings relating to sessions (which all start with 'session.' - see https://www.php.net/manual/en/session.configuration.php ). If you can then trace when / where this code is called, this might help you work out what's going on.
When the issue does occur, try to note down what you were doing when it happened. What were the last few actions you did? These may help you to work out how to reproduce the issue.
As you appear to be using WooCommerce, I would try their support forums / chat as they may know of issues specific to that application or any popular plugins / extensions: https://developer.woocommerce.com/
You might also want to try forums / chat for WordPress as WooCommerce is built on that. You may also want to check all your plugins are up-to-date, look for any which haven't been updated by their developers in a long time and disable any which aren't being
used. |