Repository navigation
Networks and Sites: Avoid a "headers already sent" warning when wp-cron.php is requested on a site that does not exist - #14859
Conversation
…ron.php` is requested on a site that does not exist. `wp-cron.php` finishes the response with `fastcgi_finish_request()` or `litespeed_finish_request()` before loading WordPress. On a subdomain network, a request for a site that does not exist then reaches the redirect in `ms-settings.php` after the headers were sent, and every such request logs "Cannot modify header information - headers already sent". Bots that probe random subdomains fill error logs this way. Only send the redirect header when headers have not been sent. The request still ends at the same point. See #53244. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
wp-cron.phpfinishes the response withfastcgi_finish_request()orlitespeed_finish_request()before loading WordPress ([44488]). On a subdomain network, a request for a site that does not exist then reaches the redirect inms-settings.phpafter the headers were sent, and every such request logs "Cannot modify header information - headers already sent". This only sends the redirect header when headers have not been sent; the request still ends at the same point.The ticket suggests sending that case to
ms_not_installed()instead. For front-end requests that callsdead_db(), which runs adb-error.phpdrop-in or reports a database error for a site that simply does not exist, so this keeps the existing quiet exit.Trac ticket: https://core.trac.wordpress.org/ticket/53244
Testing
No PHPUnit test: the code runs during the multisite bootstrap, sends a header and exits. Reproduced instead with PHP-FPM 8.3 and FastCGI requests on a throwaway subdomain network running trunk:
GET nosuchsite.<network>/wp-cron.php?doing_wp_cron=1: without the patch,PHP Warning: Cannot modify header information - headers already sent in .../ms-settings.php on line 84; with it, no warning.GET nosuchsite.<network>/wp-login.phpstill returns302 Location: http://<network>/wp-signup.php?new=nosuchsite.wp-cron.phpon the existing main site runs without warnings.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: reproducing the warning on PHP-FPM, drafting the fix, and running the checks above. I reviewed every line.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code