mike Mon, 16 Jan 2012 17:51:35 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=322374
Log: Fix bug #60768 Output buffer not discarded in php_output_handler_op(): * if appending to buffer succeeds, just return HANDLER_NO_DATA and do nothing else * if a zero sized string or true is returned from the handler function, reset the context as well as the handler's buffer Bug: https://bugs.php.net/60768 (error getting bug information) Changed paths: U php/php-src/branches/PHP_5_4/NEWS U php/php-src/branches/PHP_5_4/main/output.c A php/php-src/branches/PHP_5_4/tests/output/bug60768.phpt U php/php-src/trunk/main/output.c A php/php-src/trunk/tests/output/bug60768.phpt Modified: php/php-src/branches/PHP_5_4/NEWS =================================================================== --- php/php-src/branches/PHP_5_4/NEWS 2012-01-16 16:10:50 UTC (rev 322373) +++ php/php-src/branches/PHP_5_4/NEWS 2012-01-16 17:51:35 UTC (rev 322374) @@ -5,6 +5,7 @@ - Core: . Restoring $_SERVER['REQUEST_TIME'] as a long and introducing $_SERVER['REQUEST_TIME_FLOAT'] to include microsecond precision. (Patrick) + . Fixed bug #60768 (Output buffer not discarded) (Mike) - Pdo Firebird: . Fixed bug #47415 (segfaults when passing lowercased column name to Modified: php/php-src/branches/PHP_5_4/main/output.c =================================================================== --- php/php-src/branches/PHP_5_4/main/output.c 2012-01-16 16:10:50 UTC (rev 322373) +++ php/php-src/branches/PHP_5_4/main/output.c 2012-01-16 17:51:35 UTC (rev 322374) @@ -885,7 +885,8 @@ /* storable? */ if (php_output_handler_append(handler, &context->in TSRMLS_CC) && !context->op) { - status = PHP_OUTPUT_HANDLER_NO_DATA; + context->op = original_op; + return PHP_OUTPUT_HANDLER_NO_DATA; } else { /* need to start? */ if (!(handler->flags & PHP_OUTPUT_HANDLER_STARTED)) { @@ -961,14 +962,14 @@ handler->buffer.used = 0; handler->buffer.size = 0; break; + case PHP_OUTPUT_HANDLER_NO_DATA: + /* handler ate all */ + php_output_context_reset(context); + /* no break */ case PHP_OUTPUT_HANDLER_SUCCESS: /* no more buffered data */ handler->buffer.used = 0; break; - case PHP_OUTPUT_HANDLER_NO_DATA: - /* handler ate all */ - php_output_context_reset(context); - break; } context->op = original_op; Added: php/php-src/branches/PHP_5_4/tests/output/bug60768.phpt =================================================================== --- php/php-src/branches/PHP_5_4/tests/output/bug60768.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/tests/output/bug60768.phpt 2012-01-16 17:51:35 UTC (rev 322374) @@ -0,0 +1,25 @@ +--TEST-- +Bug #60768 Output buffer not discarded +--FILE-- +<?php + +global $storage; + +ob_start(function($buffer) use (&$storage) { $storage .= $buffer; }, 20); + +echo str_repeat("0", 20); // fill in the buffer + +for($i = 0; $i < 10; $i++) { + echo str_pad($i, 9, ' ', STR_PAD_LEFT) . "\n"; // full buffer dumped every time +} + +ob_end_flush(); + +printf("Output size: %d, expected %d\n", strlen($storage), 20 + 10 * 10); + +?> +DONE +--EXPECT-- +Output size: 120, expected 120 +DONE + Modified: php/php-src/trunk/main/output.c =================================================================== --- php/php-src/trunk/main/output.c 2012-01-16 16:10:50 UTC (rev 322373) +++ php/php-src/trunk/main/output.c 2012-01-16 17:51:35 UTC (rev 322374) @@ -885,7 +885,8 @@ /* storable? */ if (php_output_handler_append(handler, &context->in TSRMLS_CC) && !context->op) { - status = PHP_OUTPUT_HANDLER_NO_DATA; + context->op = original_op; + return PHP_OUTPUT_HANDLER_NO_DATA; } else { /* need to start? */ if (!(handler->flags & PHP_OUTPUT_HANDLER_STARTED)) { @@ -961,14 +962,14 @@ handler->buffer.used = 0; handler->buffer.size = 0; break; + case PHP_OUTPUT_HANDLER_NO_DATA: + /* handler ate all */ + php_output_context_reset(context); + /* no break */ case PHP_OUTPUT_HANDLER_SUCCESS: /* no more buffered data */ handler->buffer.used = 0; break; - case PHP_OUTPUT_HANDLER_NO_DATA: - /* handler ate all */ - php_output_context_reset(context); - break; } context->op = original_op; Added: php/php-src/trunk/tests/output/bug60768.phpt =================================================================== --- php/php-src/trunk/tests/output/bug60768.phpt (rev 0) +++ php/php-src/trunk/tests/output/bug60768.phpt 2012-01-16 17:51:35 UTC (rev 322374) @@ -0,0 +1,25 @@ +--TEST-- +Bug #60768 Output buffer not discarded +--FILE-- +<?php + +global $storage; + +ob_start(function($buffer) use (&$storage) { $storage .= $buffer; }, 20); + +echo str_repeat("0", 20); // fill in the buffer + +for($i = 0; $i < 10; $i++) { + echo str_pad($i, 9, ' ', STR_PAD_LEFT) . "\n"; // full buffer dumped every time +} + +ob_end_flush(); + +printf("Output size: %d, expected %d\n", strlen($storage), 20 + 10 * 10); + +?> +DONE +--EXPECT-- +Output size: 120, expected 120 +DONE +
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php