Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added error mask to set_error_handler()

Patch by Christian Schneider <cschneid@cschneid.com>
  • Loading branch information...
commit a72c1ab93be75e9e206e6ba90fe04c2676110e72 1 parent 170476d
@zsuraski zsuraski authored
View
19 Zend/zend_builtin_functions.c
@@ -934,19 +934,20 @@ ZEND_FUNCTION(trigger_error)
/* }}} */
-/* {{{ proto string set_error_handler(string error_handler)
+/* {{{ proto string set_error_handler(string error_handler [, int error_types])
Sets a user-defined error handler function. Returns the previously defined error handler, or false on error */
ZEND_FUNCTION(set_error_handler)
{
- zval **error_handler;
+ zval *error_handler;
zend_bool had_orig_error_handler=0;
char *error_handler_name = NULL;
+ long error_type = E_ALL;
- if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &error_handler)==FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
+ return;
}
- if (!zend_is_callable(*error_handler, 0, &error_handler_name)) {
+ if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
efree(error_handler_name);
@@ -958,17 +959,19 @@ ZEND_FUNCTION(set_error_handler)
had_orig_error_handler = 1;
*return_value = *EG(user_error_handler);
zval_copy_ctor(return_value);
+ zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
}
ALLOC_ZVAL(EG(user_error_handler));
- if (!zend_is_true(*error_handler)) { /* unset user-defined handler */
+ if (!zend_is_true(error_handler)) { /* unset user-defined handler */
FREE_ZVAL(EG(user_error_handler));
EG(user_error_handler) = NULL;
RETURN_TRUE;
}
- *EG(user_error_handler) = **error_handler;
+ EG(user_error_handler_error_reporting) = (int)error_type;
+ *EG(user_error_handler) = *error_handler;
zval_copy_ctor(EG(user_error_handler));
if (!had_orig_error_handler) {
@@ -988,6 +991,8 @@ ZEND_FUNCTION(restore_error_handler)
if (zend_ptr_stack_num_elements(&EG(user_error_handlers))==0) {
EG(user_error_handler) = NULL;
} else {
+ EG(user_error_handler_error_reporting) = zend_stack_int_top(&EG(user_error_handlers_error_reporting));
+ zend_stack_del_top(&EG(user_error_handlers_error_reporting));
EG(user_error_handler) = zend_ptr_stack_pop(&EG(user_error_handlers));
}
RETURN_TRUE;
View
4 Zend/zend_execute_API.c
@@ -167,6 +167,7 @@ void init_executor(TSRMLS_D)
EG(current_execute_data) = NULL;
+ zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_init(&EG(user_error_handlers));
zend_ptr_stack_init(&EG(user_exception_handlers));
@@ -229,6 +230,8 @@ void shutdown_executor(TSRMLS_D)
FREE_ZVAL(zeh);
}
+ zend_stack_destroy(&EG(user_error_handlers_error_reporting));
+ zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_clean(&EG(user_error_handlers), ZVAL_DESTRUCTOR, 1);
zend_ptr_stack_clean(&EG(user_exception_handlers), ZVAL_DESTRUCTOR, 1);
} zend_end_try();
@@ -287,6 +290,7 @@ void shutdown_executor(TSRMLS_D)
zend_hash_destroy(&EG(included_files));
zend_ptr_stack_destroy(&EG(arg_types_stack));
+ zend_stack_destroy(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_destroy(&EG(user_error_handlers));
zend_ptr_stack_destroy(&EG(user_exception_handlers));
zend_objects_store_destroy(&EG(objects_store));
View
2  Zend/zend_globals.h
@@ -214,8 +214,10 @@ struct _zend_executor_globals {
zval *garbage[2];
int garbage_ptr;
+ int user_error_handler_error_reporting;
zval *user_error_handler;
zval *user_exception_handler;
+ zend_stack user_error_handlers_error_reporting;
zend_ptr_stack user_error_handlers;
zend_ptr_stack user_exception_handlers;
View
5 Zend/zend_operators.c
@@ -33,8 +33,13 @@
#include "ext/bcmath/number.h"
#endif
+<<<<<<< zend_operators.c
+#define LONG_SIGN_MASK (1L << (8*SIZEOF_LONG-1))
+
+=======
#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
+>>>>>>> 1.162
ZEND_API int zend_atoi(const char *str, int str_len)
{
int retval;
Please sign in to comment.
Something went wrong with that request. Please try again.