@- 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)
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
OG(ob_block_size) = 0;
OG(ob_text_length) = 0;
OG(implicit_flush) = 0;
+ OG(output_start_filename) = NULL;
+ OG(output_start_lineno) = 0;
}
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);
}
}
+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);
+}
+
+
/*
* Local variables:
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
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;
}
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:
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;
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
OG(ob_block_size) = 0;
OG(ob_text_length) = 0;
OG(implicit_flush) = 0;
+ OG(output_start_filename) = NULL;
+ OG(output_start_lineno) = 0;
}
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);
}
}
+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);
+}
+
+
/*
* Local variables:
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