Index: wp-admin/includes/class-wp-upgrader.php =================================================================== --- wp-admin/includes/class-wp-upgrader.php (revision 18904) +++ wp-admin/includes/class-wp-upgrader.php (working copy) @@ -1239,8 +1239,7 @@ } function flush_output() { - wp_ob_end_flush_all(); - flush(); + wp_ob_end_flush_all(true); } } Index: wp-includes/functions.php =================================================================== --- wp-includes/functions.php (revision 18904) +++ wp-includes/functions.php (working copy) @@ -3275,13 +3275,75 @@ * Flush all output buffers for PHP 5.2. * * Make sure all output buffers are flushed before our singletons our destroyed. - * + * Only use $disable_compression for pages that need to be updated continuously, like updating the core, + * or installing plugins, etc. + * + * Turn off compression - make sure to flush the buffer BEFORE + * turning off compression, see comment from Sam Yong + * @link http://php.net/manual/en/function.ob-end-clean.php + * + * Turn off mod_deflate + * @link http://httpd.apache.org/docs/2.2/env.html#no-gzip + * + * ob_gzhandler will manage its own headers. If you call ob_start('ob_gzhandler') and ob_end_clean() + * immediately afterwards, it will still send a Content-Encoding: gzip header, but the page will not + * be compressed, this usually leads to an encoding error in the browser + * @link http://us.php.net/ob_gzhandler + * + * For a more detailed explanation of this function, see + * @link http://core.trac.wordpress.org/ticket/18525 + * + * @param bool $disable_compression Turn off zlib / gzip compression, attempt to defeat chunking. + * @return void * @since 2.2.0 */ -function wp_ob_end_flush_all() { +function wp_ob_end_flush_all($disable_compression = false) { + + // Send this string to fill up any buffers that php / apache / browser might have + $buffer_string = ''; // 4096 bytes + + // If the script is called through CLI for any reason, bail + if ( 'cli' == php_sapi_name() ) + return; + + // ob_gzhandler manages http headers. When undoing it with + // ob_end_flush, the result is "Warning - headers already sent ..." + // just bail + if (in_array('ob_gzhandler', ob_list_handlers())) { + ob_flush(); + return; + } + + // Tell apache to send an uncompressed non-chunked response + if ( $disable_compression && !headers_sent() && function_exists('apache_setenv') ) { + apache_setenv( 'no-gzip', '1' ); + } + + // Turn off any default output handlers + ini_set('output_handler', ''); + ini_set('output_buffering', false); + ini_set('implicit_flush', true); + + // Clean the output buffer $levels = ob_get_level(); - for ($i=0; $i<$levels; $i++) - ob_end_flush(); + for ($i=0; $i<$levels; $i++) { + @ob_end_flush(); + } + + // Turn off the zlib compression handler + if ( $disable_compression ) { + if ( !headers_sent() && ini_get('zlib.output_handler') ) { + ini_set('zlib.output_handler', ''); + ini_set('zlib.output_compression', 0); + } + + // Pad the output by a 4K block to ensure that the server / browser + // considers the output sufficient + if (headers_sent()) { + echo $buffer_string; + flush(); + } + } } /** Index: wp-admin/includes/misc.php =================================================================== --- wp-admin/includes/misc.php (revision 18904) +++ wp-admin/includes/misc.php (working copy) @@ -271,8 +271,7 @@ $message = $message->get_error_message(); } echo "
$message
\n"; - wp_ob_end_flush_all(); - flush(); + wp_ob_end_flush_all(true); } function wp_doc_link_parse( $content ) {