• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

PHP Warning in maintenance.php

wakabayashi-sec

New Pleskian
Server operating system version
CentOS Linux 7.7.1908
Plesk version and microupdate number
Plesk Onyx 17.8.11 Update #75
I often see following warnings in error log files:
PHP Warning: Cannot modify header information - headers already sent in (pathname)/wp-content/maintenance.php on line 16
PHP Warning: Cannot modify header information - headers already sent in (pathname)/wp-content/maintenance.php on line 17
PHP Warning: Cannot modify header information - headers already sent in (pathname)/wp-content/maintenance.php on line 18

I found maintenance.php is generated by WP Toolkit automatically and frequently (maybe daily) regenerated, so It's useless to fix the file itself.
Then, how can I deal with this warning?

WP Toolkit version is 4.10.5-4596.
 
You would not want to fix it in the maintenance.php script, because that is just fine. The problem is that another script tries to send the header again. That is why PHP logs that maintenance.php has already sent headers. You want to fix the other script that is sending headers again after maintenance.php did.
 
any errors in the code can trigger this message.
For example you can switch php version of this site, it leads to show deprecations and these deprecation occurs before maintenance.php script does its work. Could you check logs\raw http responses for other warning\deprecation\error messages?
 
Thank you for your replies.
I'm not sure what header() function does, so I looked up.

My understanding is:
1. The site is switched to the maintenance mode automatically by WordPress Toolkit for some reason.
2. Someone visited the site during the maintenance mode.
3. HTML response header is sent by maintenance.php to show the maintenance page.
4. Some other process send the header again.
5. The errors occur.

I can't figure out from the error logs what is the other process.

Then, the next question is:
Why and when WordPress Toolkit switches the site to the maintenance mode automatically?
 
Wordpress switches into maintenance mode when updates are being installed, e.g. for themes, plugins, a minor Wordpress version update. It leaves maintenance mode right afterwards.
 
Yes, I know WordPress itself switches the site to maintenance mode while updating, but is "wp-content/maintenace.php" used at that time?
I can't find any file updated around the time of errors.
"wp-content/maintenace.php" is generated by not WordPress itself but WordPress Toolkit, isn't it?
So, I think there are two kinds of maintenance mode, one is switched by WordPress itself, another by WordPress Toolkit.
I want to know about the latter one.

I'm not very familiar to Plesk and WordPress Toolkit, even to WordPress itself.
So please correct if wrong.
 
if this issue appeared recently, so something was changed. Do you switch PHP handler or something else? Maybe you install new plugins or themes?
Do you have other php warning\notices\etc in error log file?
Also, as I mentioned above, if you check your site there may be a text at the top of page about an error. Could you share is there something before opening "html" tag of page?

maintenance mode means you have another script that returns a stub when someone tries to access any page. This script is "wp-content/maintenace.php"
 
Back
Top