[wp-trac] [WordPress Trac] #50387: Cannot modify header information - headers already sent for "nocache_headers()"

WordPress Trac noreply at wordpress.org
Sun Jun 14 10:13:44 UTC 2020


#50387: Cannot modify header information - headers already sent for
"nocache_headers()"
--------------------------+-----------------------------
 Reporter:  malthert      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 function nocache_headers needs to be modified to not try to set/remove
 headers when the headers were already sent to avoid generating a notice.

 Optionally it would also make sense to change the return type to bool, so
 we can return false in case the headers were already sent.

 Suggestion (would be better with return false; though):

 {{{
 function nocache_headers() {
         if ( headers_sent() ) {
                 return;
         }
 }}}

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


More information about the wp-trac mailing list