[wp-trac] [WordPress Trac] #46417: ErrorException with start_session on wp_cron

WordPress Trac noreply at wordpress.org
Tue Mar 5 09:23:00 UTC 2019


#46417: ErrorException with start_session on wp_cron
--------------------------+-----------------------------
 Reporter:  herrvigg      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 With WP5.1 i had some new ErrorException raised on calls to wp-cron.php:
 {{{
 session_start(): Cannot start session when headers already sent
 }}}

 Part of my code in functions.php (and other third-party components) was
 doing this:

 {{{#!php
 <?php
 if(!session_id()) {
     session_start(); // worked before WP5.1 (so it is handled before
 headers sent)
 }
 }}}

 I actually did not need that session handling for my CRON so i could
 disable all this part when DOING_CRON is defined, solving the problem. But
 it's a workaround.

 Peter Wilson is aware of this problem:
 > This is related to #18738, with further details in the associated dev-
 note, as sessions can not be created after `fastcgi_finish_request()`
 runs.

 So he asked me to create this ticket for follow-up. It looks like a small
 regression but it can be problematic in some cases.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46417>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list