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

WordPress Trac noreply at wordpress.org
Sun Oct 20 22:35:34 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:  has-patch needs-testing  |     Focuses:
-------------------------------------+------------------------------

Comment (by normancates):

 I've been having this error on practically every site I've ever used.

 It certainly seems to be related to zlib compression being on.

 And has been present as a problem for MANY years.

 I posted this the other day, and got refered to Bug Trac. And found this
 issue. So yes, please can WP implement a fix to this problem. It's a
 common problem that seems easy to fix.

 ------------------------------------

 Regarding the wp_ob_end_flush_all() function. I've been trying to fix this
 for ages.

 Recently in some frustration I subtracted 1 from the $levels variable.

 function wp_ob_end_flush_all() {
 // print wp_debug_backtrace_summary();
 $levels = ob_get_level();
 for ( $i = 0; $i < $levels-1; $i++ ) {
 ob_end_flush();
 }
 }

 And the warning went away. This seems MAD if this is ACTUALLY the
 solution. Because I see a lot of frustrated and puzzled people having this
 problem.

 I decided to dig a little deeper and find the PHP function ob_end_flush()

 https://www.php.net/manual/en/function.ob-end-flush.php

 On this page there are some user comments (from many years ago to be sure)
 about zlib compression increasing the level by 1?

 I certainly have zlib compression turned on for my sites.

 And so do most people who are having this problem. (And no, turning off
 compression is NOT an acceptable option, despite all the people who
 suggest it.)

 Then I found this little gem under Examples:

 <?php
 while (@ob_end_flush());
 ?>

 So, I decided to try it in the WP function

 function wp_ob_end_flush_all() {
 while (@ob_end_flush());
 }

 And still, no warnings are being thrown up.

 IS this a legitimate fix? IS there anything to say this is a problem to
 do?

 I realise this is just suppressing the warning for this command. Is that a
 problem? My understanding is that this may slow execution down slightly?

 ---------------------------

 I just wanted to add my voice to ask to get this fixed.

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


More information about the wp-trac mailing list