[wp-trac] [WordPress Trac] #46417: ErrorException with start_session on wp_cron
WordPress Trac
noreply at wordpress.org
Sat Mar 16 07:04:15 UTC 2019
#46417: ErrorException with start_session on wp_cron
--------------------------+----------------------------
Reporter: herrvigg | Owner: peterwilsoncc
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Cron API | Version: 5.1
Severity: normal | Resolution: wontfix
Keywords: | Focuses:
--------------------------+----------------------------
Changes (by peterwilsoncc):
* status: assigned => closed
* resolution: => wontfix
* milestone: 5.1.2 =>
Comment:
Having considered this, I've decided to close the ticket as wontfix.
The warning is thrown as a result of plugins failing to check the outcome
`header_sent()` prior to starting a session. `fastcgi_finish_request()`
blocks the further sending of headers within PHP.
WordPress's plugin architecture requires such a check before setting
headers, a practice followed by
[https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-
includes/functions.php?marks=3060-3064#L3060 WordPress Core's code].
Rather than checking `DOING_CRON` the recommended approach is to use:
{{{#!php
<?php
if ( ! headers_sent() ) {
header( 'X-Ticket: 46417' );
// or redirects, starting sessions, setting cookies, etc.
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46417#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list