aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-06-26 20:40:25 +0200
committerAndreas Fischer <bantu@phpbb.com>2011-06-26 20:40:25 +0200
commitcdc23a987749bb806555fa80b2537b39d2baaa6d (patch)
tree5e0eb652dece4cd47bee0f72d6a22f6a161ccb3c
parent0e067ec3c272a74fae4744b787bef83504d8e9c4 (diff)
parentf249287dc9ae531042f265d3f988eb3e674c376f (diff)
downloadforums-cdc23a987749bb806555fa80b2537b39d2baaa6d.tar
forums-cdc23a987749bb806555fa80b2537b39d2baaa6d.tar.gz
forums-cdc23a987749bb806555fa80b2537b39d2baaa6d.tar.bz2
forums-cdc23a987749bb806555fa80b2537b39d2baaa6d.tar.xz
forums-cdc23a987749bb806555fa80b2537b39d2baaa6d.zip
Merge branch 'prep-release-3.0.9' into develop-olympus
* prep-release-3.0.9: [ticket/10188] Prevent semi-compressed output
-rw-r--r--phpBB/includes/functions.php31
1 files changed, 15 insertions, 16 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index a89b47b170..d05cccc440 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3758,21 +3758,6 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
{
- // flush the content, else we get a white page if output buffering is on
- if (ob_get_level() > 0)
- {
- @ob_flush();
- }
-
- // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;)
- if (!empty($config['gzip_compress']))
- {
- if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level())
- {
- @ob_flush();
- }
- }
-
// remove complete path to installation, with the risk of changing backslashes meant to be there
$errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
$msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
@@ -4332,7 +4317,21 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// gzip_compression
if ($config['gzip_compress'])
{
- if (@extension_loaded('zlib') && !headers_sent())
+ // to avoid partially compressed output resulting in blank pages in
+ // the browser or error messages, compression is disabled in a few cases:
+ //
+ // 1) if headers have already been sent, this indicates plaintext output
+ // has been started so further content must not be compressed
+ // 2) the length of the current output buffer is non-zero. This means
+ // there is already some uncompressed content in this output buffer
+ // so further output must not be compressed
+ // 3) if more than one level of output buffering is used because we
+ // cannot test all output buffer level content lengths. One level
+ // could be caused by php.ini output_buffering. Anything
+ // beyond that is manual, so the code wrapping phpBB in output buffering
+ // can easily compress the output itself.
+ //
+ if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0)
{
ob_start('ob_gzhandler');
}