robinf Sun Dec 28 19:50:58 2008 UTC Added files: /php-src/tests/output bug46903.phpt bug46900.phpt
Modified files: /php-src/tests/output ob_start_basic_004.phpt ob_start_basic_002.phpt ob_015.phpt ob_014.phpt /php-src/main output.c Log: Fix bugs #46900 and #46903. http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_start_basic_004.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/tests/output/ob_start_basic_004.phpt diff -u php-src/tests/output/ob_start_basic_004.phpt:1.2 php-src/tests/output/ob_start_basic_004.phpt:1.3 --- php-src/tests/output/ob_start_basic_004.phpt:1.2 Thu Dec 18 15:20:10 2008 +++ php-src/tests/output/ob_start_basic_004.phpt Sun Dec 28 19:50:58 2008 @@ -1,7 +1,5 @@ --TEST-- ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size. ---XFAIL-- -Special behaviour when chunk_size set to 1 is not honoured on PHP6. See bug 46903. --FILE-- <?php /* http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_start_basic_002.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/tests/output/ob_start_basic_002.phpt diff -u php-src/tests/output/ob_start_basic_002.phpt:1.2 php-src/tests/output/ob_start_basic_002.phpt:1.3 --- php-src/tests/output/ob_start_basic_002.phpt:1.2 Thu Dec 18 15:20:10 2008 +++ php-src/tests/output/ob_start_basic_002.phpt Sun Dec 28 19:50:58 2008 @@ -1,7 +1,5 @@ --TEST-- ob_start(): Check behaviour with various callback return values. ---XFAIL-- -PHP6 behaves differently from PHP5 when callback returns null. See bug 46900. --FILE-- <?php function return_empty_string($string) { http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_015.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/tests/output/ob_015.phpt diff -u php-src/tests/output/ob_015.phpt:1.2 php-src/tests/output/ob_015.phpt:1.3 --- php-src/tests/output/ob_015.phpt:1.2 Tue Aug 22 08:16:37 2006 +++ php-src/tests/output/ob_015.phpt Sun Dec 28 19:50:58 2008 @@ -4,8 +4,19 @@ <?php ob_start("str_rot13", 1); echo "foo\n"; +// str_rot13 expects 1 param and returns NULL when passed 2 params. +// It is invoked with 2 params when used as an OB callback. +// Therefore, there will be no data in the buffer. This is expected: see bug 46900. +ob_end_flush(); + +// Show the error. +print_r(error_get_last()); ?> --EXPECTF-- -foo - -Warning: str_rot13() expects exactly 1 parameter, 2 given in %s on line %d +Array +( + [type] => 2 + [message] => str_rot13() expects exactly 1 parameter, 2 given + [file] => %s + [line] => 7 +) \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_014.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/tests/output/ob_014.phpt diff -u php-src/tests/output/ob_014.phpt:1.2 php-src/tests/output/ob_014.phpt:1.3 --- php-src/tests/output/ob_014.phpt:1.2 Tue Aug 22 08:16:37 2006 +++ php-src/tests/output/ob_014.phpt Sun Dec 28 19:50:58 2008 @@ -2,13 +2,21 @@ output buffering - failure --FILE-- <?php -/* - * apparently the error handler cannot get the current function name on shutdown - */ ob_start("str_rot13"); echo "foo\n"; +// str_rot13 expects 1 param and returns NULL when passed 2 params. +// It is invoked with 2 params when used as an OB callback. +// Therefore, there will be no data in the buffer. This is expected: see bug 46900. +ob_end_flush(); + +// Show the error. +print_r(error_get_last()); ?> --EXPECTF-- -foo - -Warning: (null)() expects exactly 1 parameter, 2 given in %s on line %d +Array +( + [type] => 2 + [message] => str_rot13() expects exactly 1 parameter, 2 given + [file] => %s + [line] => 7 +) \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/main/output.c?r1=1.214&r2=1.215&diff_format=u Index: php-src/main/output.c diff -u php-src/main/output.c:1.214 php-src/main/output.c:1.215 --- php-src/main/output.c:1.214 Mon Aug 18 07:45:59 2008 +++ php-src/main/output.c Sun Dec 28 19:50:58 2008 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.214 2008/08/18 07:45:59 tony2001 Exp $ */ +/* $Id: output.c,v 1.215 2008/12/28 19:50:58 robinf Exp $ */ #ifndef PHP_OUTPUT_DEBUG # define PHP_OUTPUT_DEBUG 0 @@ -983,7 +983,7 @@ ZVAL_LONG(ob_mode, (long) context->op); zend_fcall_info_argn(&handler->func.user->fci TSRMLS_CC, 2, &ob_data, &ob_mode); -#define PHP_OUTPUT_USER_SUCCESS(retval) (retval && (Z_TYPE_P(retval) != IS_NULL) && (Z_TYPE_P(retval) != IS_BOOL || Z_BVAL_P(retval))) +#define PHP_OUTPUT_USER_SUCCESS(retval) (retval && !(Z_TYPE_P(retval) == IS_BOOL && Z_BVAL_P(retval)==0)) if (SUCCESS == zend_fcall_info_call(&handler->func.user->fci, &handler->func.user->fcc, &retval, NULL TSRMLS_CC) && PHP_OUTPUT_USER_SUCCESS(retval)) { /* user handler may have returned TRUE */ status = PHP_OUTPUT_HANDLER_NO_DATA; @@ -1342,6 +1342,8 @@ } if (chunk_size < 0) { chunk_size = 0; + } else if (chunk_size == 1) { + chunk_size = 4096; } if (SUCCESS != php_output_start_user(output_handler, chunk_size, flags TSRMLS_CC)) { http://cvs.php.net/viewvc.cgi/php-src/tests/output/bug46903.phpt?view=markup&rev=1.1 Index: php-src/tests/output/bug46903.phpt +++ php-src/tests/output/bug46903.phpt --TEST-- Bug #46903 (ob_start(): Special $chunk_size value of 1 is not honoured in HEAD) --FILE-- <?php function flushCounter($input) { static $counter=0; return '[' . ++$counter . "] $input \n"; } // This should set the buffer size to 4096 ob_start('flushCounter', 1); // Get the buffer size: $bufferInfo = ob_get_status(true); var_dump($bufferInfo[0]['chunk_size']); // If the buffer size is >1, these two chars should // come out as part of a single flush: echo "1"; echo "2"; ?> --EXPECTF-- [1] int(4096) 12 http://cvs.php.net/viewvc.cgi/php-src/tests/output/bug46900.phpt?view=markup&rev=1.1 Index: php-src/tests/output/bug46900.phpt +++ php-src/tests/output/bug46900.phpt --TEST-- Bug #46900 (Unexpected behaviour in HEAD when output buffer callback returns null) --FILE-- <?php function return_null($string) { return null; } ob_start('return_null'); echo "You shouldn't see this.\n"; ob_end_flush(); echo 'done'; ?> --EXPECTF-- done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php