r71799 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71798‎ | r71799 | r71800 >
Date:18:39, 27 August 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Fix code detecting whether there's any existing output buffering or output that could mess up our own. It used to bail out whenever ob_get_level() did not return zero, but at least in my PHP and the one on TWN it's always returning 1 (further inspection turned up that this refers to the 'default output buffer' presumably put in place by PHP). So now check for level == 1 and an empty buffer, and set up our own buffering in that case too. Will merge to trunk after running this by Tim
Modified paths:
  • /branches/resourceloader/phase3/includes/WebStart.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/WebStart.php
@@ -124,10 +124,14 @@
125125
126126 wfProfileIn( 'WebStart.php-ob_start' );
127127 # Initialise output buffering
128 -if ( ob_get_level() ) {
129 - # Someone's been mixing configuration data with code!
130 - # How annoying.
131 -} elseif ( !defined( 'MW_NO_OUTPUT_BUFFER' ) ) {
 128+
 129+# Check that there is no previous output or previously set up buffers, because
 130+# that would cause us to potentially mix gzip and non-gzip output, creating a
 131+# big mess.
 132+# In older versions of PHP ob_get_level() returns 0 if there is no buffering or
 133+# previous output, in newer versions the default output buffer is always set up
 134+# and ob_get_level() returns 1. In this case we check that the buffer is empty.
 135+if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ( ob_get_level() == 0 || ( ob_get_level() == 1 && ob_get_contents() === '' ) ) ) {
132136 require_once( "$IP/includes/OutputHandler.php" );
133137 ob_start( 'wfOutputHandler' );
134138 }

Status & tagging log