[wp-trac] [WordPress Trac] #22430: wp_ob_end_flush_all bug when zlib.output_compression = On

WordPress Trac noreply at wordpress.org
Sat Sep 28 21:00:24 UTC 2019


#22430: wp_ob_end_flush_all bug when zlib.output_compression = On
-----------------------------+------------------------------
 Reporter:  Matthias Reuter  |       Owner:  (none)
     Type:  defect (bug)     |      Status:  reopened
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:  2.8
 Severity:  major            |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by openwrite):

 I've been running into this error quite a bit recently during plugin
 development. The fix I've put in place is similar to the suggestion from
 @bobbingwide (I actually just submitted it as a WordPress plugin, before
 finding this), and reads as follows:

 {{{#!php
 //define fixed function
 function wp_ob_end_flush_all_fixed() {
         $start = (int) ini_get('zlib.output_compression');
         $levels = ob_get_level();
         for ( $i = $start; $i < $levels; $i++ ) {
                 ob_end_flush();
         }
 }

 //remove original callback
 remove_action('shutdown', 'wp_ob_end_flush_all', 1);

 //add fixed callback
 add_action('shutdown', 'wp_ob_end_flush_all_fixed', 1);
 }}}

 My rationale was that when zlib.compression is on, the starting buffer
 level should always be treated as 1. This allows all additional buffers to
 be cleared and doesn't impact installs where zlib is off. There might be
 reasons I'm not aware of that would cause issues in other scenarios, but
 since putting this fix in place I haven't experienced any further issues.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/22430#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list