@@ -1179,35 +1179,28 @@ ZEND_FUNCTION(trigger_error)
1179
1179
/* {{{ Sets a user-defined error handler function. Returns the previously defined error handler, or false on error */
1180
1180
ZEND_FUNCTION (set_error_handler )
1181
1181
{
1182
- zval * error_handler ;
1182
+ zend_fcall_info fci ;
1183
+ zend_fcall_info_cache fcc ;
1183
1184
zend_long error_type = E_ALL ;
1184
1185
1185
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "z|l" , & error_handler , & error_type ) == FAILURE ) {
1186
+ /* callable argument corresponds to the error handler */
1187
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "f!|l" , & fci , & fcc , & error_type ) == FAILURE ) {
1186
1188
RETURN_THROWS ();
1187
1189
}
1188
1190
1189
- if (Z_TYPE_P (error_handler ) != IS_NULL ) { /* NULL == unset */
1190
- if (!zend_is_callable (error_handler , 0 , NULL )) {
1191
- zend_string * error_handler_name = zend_get_callable_name (error_handler );
1192
- zend_argument_type_error (1 , "must be a valid callback" );
1193
- zend_string_release_ex (error_handler_name , 0 );
1194
- RETURN_THROWS ();
1195
- }
1196
- }
1197
-
1198
1191
if (Z_TYPE (EG (user_error_handler )) != IS_UNDEF ) {
1199
1192
ZVAL_COPY (return_value , & EG (user_error_handler ));
1200
1193
}
1201
1194
1202
1195
zend_stack_push (& EG (user_error_handlers_error_reporting ), & EG (user_error_handler_error_reporting ));
1203
1196
zend_stack_push (& EG (user_error_handlers ), & EG (user_error_handler ));
1204
1197
1205
- if (Z_TYPE_P ( error_handler ) == IS_NULL ) { /* unset user-defined handler */
1198
+ if (! ZEND_FCI_INITIALIZED ( fci ) ) { /* unset user-defined handler */
1206
1199
ZVAL_UNDEF (& EG (user_error_handler ));
1207
1200
return ;
1208
1201
}
1209
1202
1210
- ZVAL_COPY (& EG (user_error_handler ), error_handler );
1203
+ ZVAL_COPY (& EG (user_error_handler ), & ( fci . function_name ) );
1211
1204
EG (user_error_handler_error_reporting ) = (int )error_type ;
1212
1205
}
1213
1206
/* }}} */
@@ -1244,33 +1237,26 @@ ZEND_FUNCTION(restore_error_handler)
1244
1237
/* {{{ Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
1245
1238
ZEND_FUNCTION (set_exception_handler )
1246
1239
{
1247
- zval * exception_handler ;
1240
+ zend_fcall_info fci ;
1241
+ zend_fcall_info_cache fcc ;
1248
1242
1249
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "z" , & exception_handler ) == FAILURE ) {
1243
+ /* callable argument corresponds to the exception handler */
1244
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "f!" , & fci , & fcc ) == FAILURE ) {
1250
1245
RETURN_THROWS ();
1251
1246
}
1252
1247
1253
- if (Z_TYPE_P (exception_handler ) != IS_NULL ) { /* NULL == unset */
1254
- if (!zend_is_callable (exception_handler , 0 , NULL )) {
1255
- zend_string * exception_handler_name = zend_get_callable_name (exception_handler );
1256
- zend_argument_type_error (1 , "must be a valid callback" );
1257
- zend_string_release_ex (exception_handler_name , 0 );
1258
- RETURN_THROWS ();
1259
- }
1260
- }
1261
-
1262
1248
if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF ) {
1263
1249
ZVAL_COPY (return_value , & EG (user_exception_handler ));
1264
1250
}
1265
1251
1266
1252
zend_stack_push (& EG (user_exception_handlers ), & EG (user_exception_handler ));
1267
1253
1268
- if (Z_TYPE_P ( exception_handler ) == IS_NULL ) { /* unset user-defined handler */
1254
+ if (! ZEND_FCI_INITIALIZED ( fci ) ) { /* unset user-defined handler */
1269
1255
ZVAL_UNDEF (& EG (user_exception_handler ));
1270
1256
return ;
1271
1257
}
1272
1258
1273
- ZVAL_COPY (& EG (user_exception_handler ), exception_handler );
1259
+ ZVAL_COPY (& EG (user_exception_handler ), & ( fci . function_name ) );
1274
1260
}
1275
1261
/* }}} */
1276
1262
0 commit comments