colder Sat Mar 8 22:17:32 2008 UTC
Modified files:
/php-src/ext/standard/tests/general_functions bug44295.phpt
/php-src/main main.c php.h php_globals.h
Log:
User error handlers no longer catch supressed errors
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug44295.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/general_functions/bug44295.phpt
diff -u /dev/null php-src/ext/standard/tests/general_functions/bug44295.phpt:1.2
--- /dev/null Sat Mar 8 22:17:32 2008
+++ php-src/ext/standard/tests/general_functions/bug44295.phpt Sat Mar 8
22:17:32 2008
@@ -0,0 +1,26 @@
+--TEST--
+user defined error handler + set_error_handling(EH_THROW)
+--SKIPIF--
+<?php if (!extension_loaded("spl") || is_dir('/this/path/does/not/exist'))
die("skip"); ?>
+--FILE--
+<?php
+$dir = '/this/path/does/not/exist';
+
+set_error_handler('my_error_handler');
+function my_error_handler() {$a = func_get_args(); print "in error handler\n";
}
+
+try {
+ print "before\n";
+ $iter = new DirectoryIterator($dir);
+ print get_class($iter) . "\n";
+ print "after\n";
+} catch (Exception $e) {
+ print "in catch: ".$e->getMessage()."\n";
+}
+?>
+==DONE==
+<?php exit(0); ?>
+--EXPECT--
+before
+in catch: DirectoryIterator::__construct(/this/path/does/not/exist): failed to
open dir: No such file or directory
+==DONE==
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.762&r2=1.763&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.762 php-src/main/main.c:1.763
--- php-src/main/main.c:1.762 Wed Mar 5 21:20:14 2008
+++ php-src/main/main.c Sat Mar 8 22:17:32 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.762 2008/03/05 21:20:14 pajoye Exp $ */
+/* $Id: main.c,v 1.763 2008/03/08 22:17:32 colder Exp $ */
/* {{{ includes
*/
@@ -878,17 +878,15 @@
/* {{{ php_suppress_errors */
PHPAPI void php_set_error_handling(error_handling_t error_handling,
zend_class_entry *exception_class TSRMLS_DC)
{
- PG(error_handling) = error_handling;
- PG(exception_class) = exception_class;
- if (PG(last_error_message)) {
- free(PG(last_error_message));
- PG(last_error_message) = NULL;
- }
- if (PG(last_error_file)) {
- free(PG(last_error_file));
- PG(last_error_file) = NULL;
+ EG(error_handling) = error_handling;
+ EG(exception_class) = exception_class;
+
+ if (error_handling == EH_NORMAL) {
+ EG(user_error_handler) = EG(user_error_handler_old);
+ } else {
+ EG(user_error_handler_old) = EG(user_error_handler);
+ EG(user_error_handler) = NULL;
}
- PG(last_error_lineno) = 0;
}
/* }}} */
@@ -933,7 +931,7 @@
}
/* according to error handling mode, suppress error, throw exception or
show it */
- if (PG(error_handling) != EH_NORMAL) {
+ if (EG(error_handling) != EH_NORMAL) {
switch (type) {
case E_ERROR:
case E_CORE_ERROR:
@@ -954,8 +952,8 @@
/* throw an exception if we are in EH_THROW mode
* but DO NOT overwrite a pending exception
*/
- if (PG(error_handling) == EH_THROW &&
!EG(exception)) {
-
zend_throw_error_exception(PG(exception_class), buffer, 0, type TSRMLS_CC);
+ if (EG(error_handling) == EH_THROW &&
!EG(exception)) {
+
zend_throw_error_exception(EG(exception_class), buffer, 0, type TSRMLS_CC);
}
efree(buffer);
return;
@@ -1847,7 +1845,8 @@
PG(last_error_message) = NULL;
PG(last_error_file) = NULL;
PG(last_error_lineno) = 0;
- PG(error_handling) = EH_NORMAL;
+ EG(error_handling) = EH_NORMAL;
+ EG(exception_class) = NULL;
PG(disable_functions) = NULL;
PG(disable_classes) = NULL;
PG(allow_url_fopen_list) = NULL;
http://cvs.php.net/viewvc.cgi/php-src/main/php.h?r1=1.242&r2=1.243&diff_format=u
Index: php-src/main/php.h
diff -u php-src/main/php.h:1.242 php-src/main/php.h:1.243
--- php-src/main/php.h:1.242 Wed Jan 30 09:56:22 2008
+++ php-src/main/php.h Sat Mar 8 22:17:32 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.242 2008/01/30 09:56:22 dmitry Exp $ */
+/* $Id: php.h,v 1.243 2008/03/08 22:17:32 colder Exp $ */
#ifndef PHP_H
#define PHP_H
@@ -277,12 +277,7 @@
END_EXTERN_C()
#define php_error zend_error
-
-typedef enum {
- EH_NORMAL = 0,
- EH_SUPPRESS,
- EH_THROW
-} error_handling_t;
+#define error_handling_t zend_error_handling_t
BEGIN_EXTERN_C()
PHPAPI void php_set_error_handling(error_handling_t error_handling,
zend_class_entry *exception_class TSRMLS_DC);
http://cvs.php.net/viewvc.cgi/php-src/main/php_globals.h?r1=1.115&r2=1.116&diff_format=u
Index: php-src/main/php_globals.h
diff -u php-src/main/php_globals.h:1.115 php-src/main/php_globals.h:1.116
--- php-src/main/php_globals.h:1.115 Mon Dec 31 07:12:18 2007
+++ php-src/main/php_globals.h Sat Mar 8 22:17:32 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_globals.h,v 1.115 2007/12/31 07:12:18 sebastian Exp $ */
+/* $Id: php_globals.h,v 1.116 2008/03/08 22:17:32 colder Exp $ */
#ifndef PHP_GLOBALS_H
#define PHP_GLOBALS_H
@@ -137,8 +137,6 @@
char *last_error_message;
char *last_error_file;
int last_error_lineno;
- error_handling_t error_handling;
- zend_class_entry *exception_class;
char *disable_functions;
char *disable_classes;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php