Skip to content

Commit 39aa59b

Browse files
committed
More error handling work (still completely disabled)
1 parent 095f1d9 commit 39aa59b

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ PHPAPI void php_print_info(int flag)
208208
}
209209
PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" align=\"right\"></a>\n");
210210
}
211-
php_printf("This program makes use of the Zend scripting language engine:<BR>%s<BR>\n", get_zend_version());
211+
php_printf("This program makes use of the Zend scripting language engine:<pre>%s</pre>\n", get_zend_version());
212212
php_info_print_box_end();
213213
}
214214

main/main.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,24 @@ PHPAPI int php_printf(const char *format, ...)
298298

299299

300300
/* extended error handling function */
301-
PHPAPI void php_error(int type, const char *format, ...)
301+
#if ZEND_NEW_ERROR_HANDLING
302+
static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list orig_args)
303+
#else
304+
PHPAPI void php_error_cb(int type, const char *format, ...)
305+
#endif
302306
{
303-
va_list args;
307+
#if !ZEND_NEW_ERROR_HANDLING
304308
char *error_filename = NULL;
305309
uint error_lineno;
310+
#endif
306311
char buffer[1024];
307312
int size = 0;
313+
va_list args;
308314
CLS_FETCH();
309315
ELS_FETCH();
310316
PLS_FETCH();
311317

318+
#if !ZEND_NEW_ERROR_HANDLING
312319
switch (type) {
313320
case E_CORE_ERROR:
314321
case E_CORE_WARNING:
@@ -344,6 +351,7 @@ PHPAPI void php_error(int type, const char *format, ...)
344351
if (!error_filename) {
345352
error_filename = "Unknown";
346353
}
354+
#endif
347355

348356
if (EG(error_reporting) & type || (type & E_CORE)) {
349357
char *error_type_str;
@@ -377,7 +385,11 @@ PHPAPI void php_error(int type, const char *format, ...)
377385

378386
/* get include file name */
379387
if (PG(log_errors) || PG(display_errors) || (!module_initialized)) {
388+
#if ZEND_NEW_ERROR_HANDLING
389+
args = orig_args;
390+
#else
380391
va_start(args, format);
392+
#endif
381393
size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
382394
va_end(args);
383395
buffer[sizeof(buffer) - 1] = 0;
@@ -419,9 +431,14 @@ PHPAPI void php_error(int type, const char *format, ...)
419431
if (PG(track_errors)) {
420432
pval *tmp;
421433

434+
#if ZEND_NEW_ERROR_HANDLING
435+
args = orig_args;
436+
#else
422437
va_start(args, format);
438+
#endif
423439
size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
424440
va_end(args);
441+
425442
buffer[sizeof(buffer) - 1] = 0;
426443

427444
ALLOC_ZVAL(tmp);
@@ -812,7 +829,7 @@ int php_module_startup(sapi_module_struct *sf)
812829

813830
php_output_startup();
814831

815-
zuf.error_function = php_error;
832+
zuf.error_function = php_error_cb;
816833
zuf.printf_function = php_printf;
817834
zuf.write_function = php_body_write_wrapper;
818835
zuf.fopen_function = php_fopen_wrapper_for_zend;

main/php.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,20 @@ extern char **environ;
242242
#endif
243243

244244
extern void phperror(char *error);
245-
extern PHPAPI void php_error(int type, const char *format, ...);
246245
extern PHPAPI int php_write(void *buf, int size);
247246
extern PHPAPI int php_printf(const char *format, ...);
248247
extern void php_log_err(char *log_message);
249248
extern int Debug(char *format, ...);
250249
extern int cfgparse(void);
251250

251+
#if ZEND_NEW_ERROR_HANDLING
252+
#define php_error zend_error
253+
#else
254+
extern PHPAPI void php_error_cb(int type, const char *format, ...);
255+
#define php_error php_error_cb
256+
#endif
257+
258+
252259
extern void html_putc(char c);
253260

254261
#define zenderror phperror

php4dll.dsp

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)