From 7a0fe29678b75a5b452114e1a4eb2075f6008778 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Fri, 16 Oct 2009 20:13:25 +0000 Subject: [PATCH] test_environment.php : check for output_handler config.php : disable output_handler (along with zlib.output_handler) --- min/config.php | 1 + min_unit_tests/test_environment.php | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/min/config.php b/min/config.php index 76199a0..b8c2592 100644 --- a/min/config.php +++ b/min/config.php @@ -154,3 +154,4 @@ $min_libPath = dirname(__FILE__) . '/lib'; // try to disable output_compression (may not have an effect) ini_set('zlib.output_compression', '0'); +ini_set('output_handler', ''); diff --git a/min_unit_tests/test_environment.php b/min_unit_tests/test_environment.php index f801569..546cf73 100644 --- a/min_unit_tests/test_environment.php +++ b/min_unit_tests/test_environment.php @@ -3,12 +3,16 @@ if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { // called directly if (isset($_GET['getOutputCompression'])) { - echo (int)ini_get('zlib.output_compression'); + echo (int)( + ini_get('zlib.output_compression') + || ini_get('output_handler') === 'ob_gzhandler' + ); exit(); } if (isset($_GET['hello'])) { // try to disable (may not work) ini_set('zlib.output_compression', '0'); + ini_set('output_handler', ''); echo 'World!'; exit(); } @@ -56,10 +60,6 @@ function test_environment() echo "!WARN: environment : Local HTTP request failed. Testing cannot continue.\n"; return; } - if ('1' === $oc) { - echo "!WARN: environment : zlib.output_compression is enabled in php.ini" - . " or .htaccess.\n"; - } $fp = fopen($thisUrl . '?hello=1', 'r', false, stream_context_create(array( 'http' => array( @@ -79,7 +79,8 @@ function test_environment() break; } } - if ($passed && stream_get_contents($fp) !== 'World!') { + $streamContents = stream_get_contents($fp); + if ($passed && $streamContents !== 'World!') { $passed = false; } assertTrue( @@ -88,11 +89,17 @@ function test_environment() ); fclose($fp); - if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { - if (! $passed) { - echo "\nReturned content should be 6 bytes and not HTTP encoded.\n" - . "Headers returned by: {$thisUrl}?hello=1\n\n"; - var_export($meta['wrapper_data']); + if (! $passed) { + echo "\nReturned content should be 6 bytes and not HTTP encoded.\n" + . "Headers returned by: {$thisUrl}?hello=1\n"; + var_export($meta['wrapper_data']); + echo "\nContent body: "; + var_export($streamContents); + echo "\n\n"; + + if ('1' === $oc) { + echo "!NOTE: environment : zlib.output_compression='On' OR " + . " output_handler='ob_gzhandler' in php.ini or .htaccess.\n"; } } }