mike Wed Aug 9 13:56:45 2006 UTC Added files: /php-src/tests/output ob_018.phpt ob_019.phpt
Modified files: /php-src/main output.c php_output.h /php-src/tests/output ob_013.phpt Log: - error message enhancements - avoid duplicate error messages - add PHP_OUTPUT_HANDLER_FLUSHABLE - add PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL - add more tests
http://cvs.php.net/viewvc.cgi/php-src/main/output.c?r1=1.186&r2=1.187&diff_format=u Index: php-src/main/output.c diff -u php-src/main/output.c:1.186 php-src/main/output.c:1.187 --- php-src/main/output.c:1.186 Wed Aug 9 10:57:46 2006 +++ php-src/main/output.c Wed Aug 9 13:56:45 2006 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.186 2006/08/09 10:57:46 mike Exp $ */ +/* $Id: output.c,v 1.187 2006/08/09 13:56:45 mike Exp $ */ #ifndef PHP_OUTPUT_DEBUG # define PHP_OUTPUT_DEBUG 0 @@ -157,6 +157,7 @@ REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_FINAL, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CLEANABLE", PHP_OUTPUT_HANDLER_CLEANABLE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FLUSHABLE", PHP_OUTPUT_HANDLER_FLUSHABLE, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_REMOVABLE", PHP_OUTPUT_HANDLER_REMOVABLE, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STDFLAGS", PHP_OUTPUT_HANDLER_STDFLAGS, CONST_CS | CONST_PERSISTENT); REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STARTED", PHP_OUTPUT_HANDLER_STARTED, CONST_CS | CONST_PERSISTENT); @@ -266,13 +267,13 @@ } /* }}} */ -/* {{{ void php_output_flush(TSRMLS_D) +/* {{{ SUCCESS|FAILURE php_output_flush(TSRMLS_D) Flush the most recent output handlers buffer */ -PHPAPI void php_output_flush(TSRMLS_D) +PHPAPI int php_output_flush(TSRMLS_D) { php_output_context context; - if (OG(active)) { + if (OG(active) && (OG(active)->flags & PHP_OUTPUT_HANDLER_FLUSHABLE)) { php_output_context_init(&context, PHP_OUTPUT_HANDLER_FLUSH TSRMLS_CC); php_output_handler_op(OG(active), &context); if (context.out.data && context.out.used) { @@ -281,7 +282,9 @@ zend_stack_push(&OG(handlers), &OG(active), sizeof(php_output_handler *)); } php_output_context_dtor(&context); + return SUCCESS; } + return FAILURE; } /* }}} */ @@ -638,7 +641,7 @@ /* }}} */ /* {{{ SUCCESS|FAILURE php_output_handler_alias_register(zval *name, php_output_handler_context_func_t func TSRMLS_DC) -+ Registers an internal output handler as alias for a user handler */ + Registers an internal output handler as alias for a user handler */ PHPAPI int php_output_handler_alias_register_ex(zval *name, php_output_handler_context_func_t func TSRMLS_DC) { if (!EG(current_module)) { @@ -661,6 +664,8 @@ case PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS: *(int *) arg = OG(running)->flags; return SUCCESS; + case PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL: + *(int *) arg = OG(running)->level; case PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE: OG(running)->flags &= ~PHP_OUTPUT_HANDLER_STDFLAGS; return SUCCESS; @@ -1165,10 +1170,10 @@ php_output_handler **current, *orphan = OG(active); if (!orphan) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete."); + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to %s buffer. No buffer to %s", discard?"discard":"send", discard?"discard":"send"); return 0; } else if (!shutdown && !(orphan->flags & PHP_OUTPUT_HANDLER_REMOVABLE)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", orphan->name); + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to %s buffer of %v (%d)", discard?"discard":"send", Z_UNIVAL_P(orphan->name), orphan->level); return 0; } else { php_output_context_init(&context, PHP_OUTPUT_HANDLER_FINAL TSRMLS_CC); @@ -1259,7 +1264,7 @@ long chunk_size = 0; long flags = PHP_OUTPUT_HANDLER_STDFLAGS; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/lb", &output_handler, &chunk_size, &flags)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags)) { RETURN_FALSE; } if (chunk_size < 0) { @@ -1286,8 +1291,10 @@ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush"); RETURN_FALSE; } - - php_output_flush(TSRMLS_C); + if (SUCCESS != php_output_flush(TSRMLS_C)) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer of %v (%d)", Z_UNIVAL_P(OG(active)->name), OG(active)->level); + RETURN_FALSE; + } RETURN_TRUE; } /* }}} */ @@ -1306,7 +1313,7 @@ RETURN_FALSE; } if (SUCCESS != php_output_clean(TSRMLS_C)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v", Z_UNIVAL_P(OG(active)->name)); + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v (%d)", Z_UNIVAL_P(OG(active)->name), OG(active)->level); RETURN_FALSE; } RETURN_TRUE; @@ -1325,11 +1332,7 @@ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush"); RETURN_FALSE; } - if (SUCCESS != php_output_end(TSRMLS_C)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v", Z_UNIVAL_P(OG(active)->name)); - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(SUCCESS == php_output_end(TSRMLS_C)); } /* }}} */ @@ -1345,11 +1348,7 @@ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete"); RETURN_FALSE; } - if (SUCCESS != php_output_discard(TSRMLS_C)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v", Z_UNIVAL_P(OG(active)->name)); - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(SUCCESS == php_output_discard(TSRMLS_C)); } /* }}} */ @@ -1366,7 +1365,7 @@ RETURN_FALSE; } if (SUCCESS != php_output_end(TSRMLS_C)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v", Z_UNIVAL_P(OG(active)->name)); + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v (%d)", Z_UNIVAL_P(OG(active)->name), OG(active)->level); } } /* }}} */ @@ -1384,7 +1383,7 @@ RETURN_FALSE; } if (SUCCESS != php_output_discard(TSRMLS_C)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v", Z_UNIVAL_P(OG(active)->name)); + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %v (%d)", Z_UNIVAL_P(OG(active)->name), OG(active)->level); } } /* }}} */ @@ -1443,7 +1442,7 @@ } /* }}} */ -/* {{{ proto false|array ob_get_status([bool full_status]) +/* {{{ proto false|array ob_get_status([bool full_status]) U Return the status of the active or all output buffers */ PHP_FUNCTION(ob_get_status) { @@ -1465,7 +1464,7 @@ } /* }}} */ -/* {{{ proto void ob_implicit_flush([int flag]) +/* {{{ proto void ob_implicit_flush([int flag]) U Turn implicit flush on/off and is equivalent to calling flush() after every output call */ PHP_FUNCTION(ob_implicit_flush) { http://cvs.php.net/viewvc.cgi/php-src/main/php_output.h?r1=1.59&r2=1.60&diff_format=u Index: php-src/main/php_output.h diff -u php-src/main/php_output.h:1.59 php-src/main/php_output.h:1.60 --- php-src/main/php_output.h:1.59 Mon Jun 12 18:18:39 2006 +++ php-src/main/php_output.h Wed Aug 9 13:56:45 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h,v 1.59 2006/06/12 18:18:39 mike Exp $ */ +/* $Id: php_output.h,v 1.60 2006/08/09 13:56:45 mike Exp $ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H @@ -38,8 +38,9 @@ /* handler ability flags */ #define PHP_OUTPUT_HANDLER_CLEANABLE 0x0010 -#define PHP_OUTPUT_HANDLER_REMOVABLE 0x0020 -#define PHP_OUTPUT_HANDLER_STDFLAGS 0x0030 +#define PHP_OUTPUT_HANDLER_FLUSHABLE 0x0020 +#define PHP_OUTPUT_HANDLER_REMOVABLE 0x0040 +#define PHP_OUTPUT_HANDLER_STDFLAGS 0x0070 /* handler status flags */ #define PHP_OUTPUT_HANDLER_STARTED 0x1000 @@ -60,8 +61,9 @@ /* handler hooks */ #define PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ 1 #define PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS 2 -#define PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE 3 -#define PHP_OUTPUT_HANDLER_HOOK_DISABLE 4 +#define PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL 3 +#define PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE 4 +#define PHP_OUTPUT_HANDLER_HOOK_DISABLE 5 #define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \ ( (s) ? \ @@ -183,7 +185,7 @@ PHPAPI int php_output_write_ascii(const char *str, size_t len TSRMLS_DC); PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC); -PHPAPI void php_output_flush(TSRMLS_D); +PHPAPI int php_output_flush(TSRMLS_D); PHPAPI void php_output_flush_all(TSRMLS_D); PHPAPI int php_output_clean(TSRMLS_D); PHPAPI void php_output_clean_all(TSRMLS_D); http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_013.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/tests/output/ob_013.phpt diff -u php-src/tests/output/ob_013.phpt:1.1 php-src/tests/output/ob_013.phpt:1.2 --- php-src/tests/output/ob_013.phpt:1.1 Fri Jun 2 19:51:43 2006 +++ php-src/tests/output/ob_013.phpt Wed Aug 9 13:56:45 2006 @@ -39,7 +39,7 @@ ( [name] => d [type] => 1 - [flags] => 4145 + [flags] => 4209 [level] => 4 [chunk_size] => 0 [buffer_size] => 16384 @@ -51,7 +51,7 @@ ( [name] => default output handler [type] => 0 - [flags] => 48 + [flags] => 112 [level] => 0 [chunk_size] => 0 [buffer_size] => 16384 @@ -62,7 +62,7 @@ ( [name] => a [type] => 1 - [flags] => 49 + [flags] => 113 [level] => 1 [chunk_size] => 0 [buffer_size] => 16384 @@ -73,7 +73,7 @@ ( [name] => b [type] => 1 - [flags] => 49 + [flags] => 113 [level] => 2 [chunk_size] => 0 [buffer_size] => 16384 @@ -84,7 +84,7 @@ ( [name] => c [type] => 1 - [flags] => 49 + [flags] => 113 [level] => 3 [chunk_size] => 0 [buffer_size] => 16384 @@ -95,7 +95,7 @@ ( [name] => d [type] => 1 - [flags] => 4145 + [flags] => 4209 [level] => 4 [chunk_size] => 0 [buffer_size] => 16384 http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_018.phpt?view=markup&rev=1.1 Index: php-src/tests/output/ob_018.phpt +++ php-src/tests/output/ob_018.phpt --TEST-- output buffering - error message nirvana bug #37714 --ENV-- HTTP_ACCEPT_ENCODING=gzip,deflate --INI-- display_errors=1 zlib.output_compression=1 --FILE-- <?php ob_start('ob_gzhandler'); ?> --EXPECTF-- http://cvs.php.net/viewvc.cgi/php-src/tests/output/ob_019.phpt?view=markup&rev=1.1 Index: php-src/tests/output/ob_019.phpt +++ php-src/tests/output/ob_019.phpt --TEST-- output buffering - flags --FILE-- <?php declare(encoding="latin1"); echo "\n==".ob_get_level()."==\n"; ob_start(null, 0, PHP_OUTPUT_HANDLER_CLEANABLE); echo "N:clean\n"; ob_clean(); ob_flush(); echo "\n==".ob_get_level()."==\n"; ob_start(null, 0, PHP_OUTPUT_HANDLER_FLUSHABLE); echo "Y:flush\n"; ob_clean(); ob_flush(); echo "\n==".ob_get_level()."==\n"; ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE); echo "N:remove-clean\n"; ob_end_clean(); echo "\n==".ob_get_level()."==\n"; ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE); echo "Y:remove-flush\n"; ob_end_flush(); echo "\n==".ob_get_level()."==\n"; ob_start(null, 0, PHP_OUTPUT_HANDLER_STDFLAGS); echo "N:standard\n"; ob_end_clean(); ?> --EXPECTF-- ==0== Notice: ob_flush(): failed to flush buffer of default output handler (0) in %sob_019.php on line %d ==1== Y:flush Notice: ob_clean(): failed to delete buffer of default output handler (1) in %sob_019.php on line %d ==2== ==2== Y:remove-flush ==2==
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php