Skip to content

Networks and Sites: Avoid a "headers already sent" warning when wp-cron.php is requested on a site that does not exist - #14859

Open
mpeshev wants to merge 1 commit into
WordPress:trunkfrom
mpeshev:53244-ms-settings-headers-sent
Open

mpeshev wants to merge 1 commit into
WordPress:trunkfrom
mpeshev:53244-ms-settings-headers-sent

Conversation

@mpeshev

@mpeshev mpeshev commented Oct 25, 2026

Copy link
Copy Markdown

wp-cron.php finishes the response with fastcgi_finish_request() or litespeed_finish_request() before loading WordPress ([44488]). 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". 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 calls dead_db(), which runs a db-error.php drop-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.php still returns 302 Location: http://<network>/wp-signup.php?new=nosuchsite.
  • wp-cron.php on 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

…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>
@github-actions

Copy link
Copy Markdown

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:

Props nofearinc.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant