cvs: /php4 SAPI.c main.c /php4/ext/standard output.c php_output.h

From: Date: Fri, 04 Feb 2000 14:54:30 +0000
Subject: cvs: /php4 SAPI.c main.c /php4/ext/standard output.c php_output.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-9809@lists.php.net to get a copy of this message
zeev Fri Feb 4 15:54:30 2000 EDT Modified files: /php4 SAPI.c main.c /php4/ext/standard output.c php_output.h Log: Use the new state functions @- If header information is sent after output has already been sent, the warning @ message will now state the filename and line number at which the first output @ was made (Zeev) Index: php4/SAPI.c diff -u php4/SAPI.c:1.41 php4/SAPI.c:1.42 --- php4/SAPI.c:1.41 Thu Jan 13 18:37:20 2000 +++ php4/SAPI.c Fri Feb 4 15:54:29 2000 @@ -229,7 +229,15 @@ SLS_FETCH(); if (SG(headers_sent)) { - sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent"); + char *output_start_filename = php_get_output_start_filename(); + int output_start_lineno = php_get_output_start_lineno(); + + if (output_start_filename) { + sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent by (output started at %s:%d)", + output_start_filename, output_start_lineno); + } else { + sapi_module.sapi_error(E_WARNING, "Cannot add header information - headers already sent"); + } efree(header_line); return FAILURE; } Index: php4/main.c diff -u php4/main.c:1.189 php4/main.c:1.190 --- php4/main.c:1.189 Sun Jan 30 21:31:40 2000 +++ php4/main.c Fri Feb 4 15:54:30 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.189 2000/01/30 20:31:40 zeev Exp $ */ +/* $Id: main.c,v 1.190 2000/02/04 14:54:30 zeev Exp $ */ #include <stdio.h> @@ -353,10 +353,10 @@ uint error_lineno; char buffer[1024]; int size = 0; + CLS_FETCH(); ELS_FETCH(); PLS_FETCH(); - switch (type) { case E_CORE_ERROR: case E_CORE_WARNING: @@ -365,21 +365,20 @@ break; case E_PARSE: case E_COMPILE_ERROR: - case E_COMPILE_WARNING: { - CLS_FETCH(); - - error_filename = zend_get_compiled_filename(); - error_lineno = CG(zend_lineno); - if (!error_filename) { - error_filename = zend_get_executed_filename(ELS_C); - } - } - break; + case E_COMPILE_WARNING: case E_ERROR: case E_NOTICE: case E_WARNING: - error_filename = zend_get_executed_filename(ELS_C); - error_lineno = zend_get_executed_lineno(ELS_C); + if (zend_is_compiling()) { + error_filename = zend_get_compiled_filename(CLS_C); + error_lineno = zend_get_compiled_lineno(CLS_C); + } else if (zend_is_executing()) { + error_filename = zend_get_executed_filename(ELS_C); + error_lineno = zend_get_executed_lineno(ELS_C); + } else { + error_filename = NULL; + error_lineno = 0; + } break; default: error_filename = NULL; Index: php4/ext/standard/output.c diff -u php4/ext/standard/output.c:1.15 php4/ext/standard/output.c:1.16 --- php4/ext/standard/output.c:1.15 Tue Jan 18 23:25:48 2000 +++ php4/ext/standard/output.c Fri Feb 4 15:54:30 2000 @@ -46,6 +46,8 @@ uint ob_block_size; uint ob_text_length; unsigned char implicit_flush; + char *output_start_filename; + int output_start_lineno; } php_output_globals; #ifdef ZTS @@ -79,6 +81,8 @@ OG(ob_block_size) = 0; OG(ob_text_length) = 0; OG(implicit_flush) = 0; + OG(output_start_filename) = NULL; + OG(output_start_lineno) = 0; } @@ -342,6 +346,18 @@ zend_bailout(); } if (php_header()) { + if (zend_is_compiling()) { + CLS_FETCH(); + + OG(output_start_filename) = zend_get_compiled_filename(CLS_C); + OG(output_start_lineno) = zend_get_compiled_lineno(CLS_C); + } else if (zend_is_executing()) { + ELS_FETCH(); + + OG(output_start_filename) = zend_get_executed_filename(ELS_C); + OG(output_start_lineno) = zend_get_executed_lineno(ELS_C); + } + OG(php_body_write) = php_ub_body_write_no_header; result = php_ub_body_write_no_header(str, str_length); } @@ -406,6 +422,22 @@ } else { php_end_implicit_flush(); } +} + + +PHPAPI char *php_get_output_start_filename() +{ + OLS_FETCH(); + + return OG(output_start_filename); +} + + +PHPAPI int php_get_output_start_lineno() +{ + OLS_FETCH(); + + return OG(output_start_lineno); } Index: php4/ext/standard/php_output.h diff -u php4/ext/standard/php_output.h:1.4 php4/ext/standard/php_output.h:1.5 --- php4/ext/standard/php_output.h:1.4 Thu Jan 13 18:37:20 2000 +++ php4/ext/standard/php_output.h Fri Feb 4 15:54:30 2000 @@ -30,7 +30,8 @@ PHPAPI int php_ob_get_buffer(pval *p); PHPAPI void php_start_implicit_flush(); PHPAPI void php_end_implicit_flush(); - +PHPAPI char *php_get_output_start_filename(); +PHPAPI int php_get_output_start_lineno(); extern zend_module_entry output_module_entry; #define phpext_output_ptr &output_module_entry

« previous php.version4 (#9809) next »