Index: wp-includes/functions.php =================================================================== --- wp-includes/functions.php (revision 18899) +++ wp-includes/functions.php (working copy) @@ -3275,13 +3275,54 @@ * 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 + * + * 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() { - $levels = ob_get_level(); - for ($i=0; $i<$levels; $i++) - ob_end_flush(); +function wp_ob_end_flush_all($disable_compression = false) { + + // If the script is called through CLI for any reason, bail + if ( 'cli' == php_sapi_name() ) + return; + + // Clean the output buffer + $levels = ob_get_level(); + for ($i=0; $i<$levels; $i++) + @ob_end_flush(); + + if ( $disable_compression ) { + if ( !headers_sent() && ini_get('zlib.output_handler') ) { + ini_set('zlib.output_handler', ''); + ini_set('zlib.output_compression', 0); + } + + // Tell apache to send an uncompressed non-chunked response + if ( 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); + + // Pad the output by a 4K block to ensure that the server / browser + // considers the output sufficient + echo ''; // 4096 bytes + flush(); + } } /** Index: wp-admin/includes/misc.php =================================================================== --- wp-admin/includes/misc.php (revision 18899) +++ 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 ) { Index: wp-admin/includes/class-wp-upgrader.php =================================================================== --- wp-admin/includes/class-wp-upgrader.php (revision 18899) +++ 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); } }