@@ -1512,48 +1512,46 @@ ZEND_FUNCTION(trigger_error)
1512
1512
ZEND_FUNCTION (set_error_handler )
1513
1513
{
1514
1514
zval * error_handler ;
1515
+ zend_bool had_orig_error_handler = 0 ;
1515
1516
char * error_handler_name = NULL ;
1516
1517
long error_type = E_ALL ;
1517
1518
1518
1519
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "z|l" , & error_handler , & error_type ) == FAILURE ) {
1519
1520
return ;
1520
1521
}
1521
1522
1522
- if (IS_NULL != Z_TYPE_P (error_handler )) {
1523
- zend_bool had_orig_error_handler = 0 ;
1524
- if (!zend_is_callable (error_handler , 0 , & error_handler_name TSRMLS_CC )) {
1525
- zend_error (E_WARNING , "%s() expects the argument (%s) to be a valid callback" ,
1526
- get_active_function_name (TSRMLS_C ), error_handler_name ?error_handler_name :"unknown" );
1527
- efree (error_handler_name );
1528
- return ;
1529
- }
1523
+ if (!zend_is_callable (error_handler , 0 , & error_handler_name TSRMLS_CC )) {
1524
+ zend_error (E_WARNING , "%s() expects the argument (%s) to be a valid callback" ,
1525
+ get_active_function_name (TSRMLS_C ), error_handler_name ?error_handler_name :"unknown" );
1530
1526
efree (error_handler_name );
1527
+ return ;
1528
+ }
1529
+ efree (error_handler_name );
1531
1530
1532
- if (EG (user_error_handler )) {
1533
- had_orig_error_handler = 1 ;
1534
- * return_value = * EG (user_error_handler );
1535
- zval_copy_ctor (return_value );
1536
- INIT_PZVAL (return_value );
1537
- zend_stack_push (& EG (user_error_handlers_error_reporting ), & EG (user_error_handler_error_reporting ), sizeof (EG (user_error_handler_error_reporting )));
1538
- zend_ptr_stack_push (& EG (user_error_handlers ), EG (user_error_handler ));
1539
- }
1540
-
1541
- ALLOC_ZVAL (EG (user_error_handler ));
1542
- EG (user_error_handler_error_reporting ) = (int )error_type ;
1543
- MAKE_COPY_ZVAL (& error_handler , EG (user_error_handler ));
1544
-
1545
- if (!had_orig_error_handler ) {
1546
- RETURN_NULL ();
1547
- }
1548
- } else { /* unset user-defined handler */
1549
- if (EG (user_error_handler )) {
1550
- zend_stack_push (& EG (user_error_handlers_error_reporting ), & EG (user_error_handler_error_reporting ), sizeof (EG (user_error_handler_error_reporting )));
1551
- zend_ptr_stack_push (& EG (user_error_handlers ), EG (user_error_handler ));
1552
- }
1531
+ if (EG (user_error_handler )) {
1532
+ had_orig_error_handler = 1 ;
1533
+ * return_value = * EG (user_error_handler );
1534
+ zval_copy_ctor (return_value );
1535
+ INIT_PZVAL (return_value );
1536
+ zend_stack_push (& EG (user_error_handlers_error_reporting ), & EG (user_error_handler_error_reporting ), sizeof (EG (user_error_handler_error_reporting )));
1537
+ zend_ptr_stack_push (& EG (user_error_handlers ), EG (user_error_handler ));
1538
+ }
1539
+ ALLOC_ZVAL (EG (user_error_handler ));
1553
1540
1541
+ if (!zend_is_true (error_handler )) { /* unset user-defined handler */
1542
+ FREE_ZVAL (EG (user_error_handler ));
1554
1543
EG (user_error_handler ) = NULL ;
1555
1544
RETURN_TRUE ;
1556
1545
}
1546
+
1547
+ EG (user_error_handler_error_reporting ) = (int )error_type ;
1548
+ * EG (user_error_handler ) = * error_handler ;
1549
+ zval_copy_ctor (EG (user_error_handler ));
1550
+ INIT_PZVAL (EG (user_error_handler ));
1551
+
1552
+ if (!had_orig_error_handler ) {
1553
+ RETURN_NULL ();
1554
+ }
1557
1555
}
1558
1556
/* }}} */
1559
1557
@@ -1587,42 +1585,41 @@ ZEND_FUNCTION(set_exception_handler)
1587
1585
{
1588
1586
zval * exception_handler ;
1589
1587
char * exception_handler_name = NULL ;
1588
+ zend_bool had_orig_exception_handler = 0 ;
1590
1589
1591
1590
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "z" , & exception_handler ) == FAILURE ) {
1592
1591
return ;
1593
1592
}
1594
1593
1595
1594
if (Z_TYPE_P (exception_handler ) != IS_NULL ) { /* NULL == unset */
1596
- zend_bool had_orig_exception_handler = 0 ;
1597
-
1598
1595
if (!zend_is_callable (exception_handler , 0 , & exception_handler_name TSRMLS_CC )) {
1599
1596
zend_error (E_WARNING , "%s() expects the argument (%s) to be a valid callback" ,
1600
- get_active_function_name (TSRMLS_C ), exception_handler_name ?exception_handler_name :"unknown" );
1597
+ get_active_function_name (TSRMLS_C ), exception_handler_name ?exception_handler_name :"unknown" );
1601
1598
efree (exception_handler_name );
1602
1599
return ;
1603
1600
}
1604
1601
efree (exception_handler_name );
1602
+ }
1605
1603
1606
- if (EG (user_exception_handler )) {
1607
- had_orig_exception_handler = 1 ;
1608
- * return_value = * EG (user_exception_handler );
1609
- zval_copy_ctor (return_value );
1610
- zend_ptr_stack_push (& EG (user_exception_handlers ), EG (user_exception_handler ));
1611
- }
1612
-
1613
- ALLOC_ZVAL (EG (user_exception_handler ));
1614
- MAKE_COPY_ZVAL (& exception_handler , EG (user_exception_handler ));
1604
+ if (EG (user_exception_handler )) {
1605
+ had_orig_exception_handler = 1 ;
1606
+ * return_value = * EG (user_exception_handler );
1607
+ zval_copy_ctor (return_value );
1608
+ zend_ptr_stack_push (& EG (user_exception_handlers ), EG (user_exception_handler ));
1609
+ }
1610
+ ALLOC_ZVAL (EG (user_exception_handler ));
1615
1611
1616
- if (!had_orig_exception_handler ) {
1617
- RETURN_NULL ();
1618
- }
1619
- } else {
1620
- if (EG (user_exception_handler )) {
1621
- zend_ptr_stack_push (& EG (user_exception_handlers ), EG (user_exception_handler ));
1622
- }
1612
+ if (Z_TYPE_P (exception_handler ) == IS_NULL ) { /* unset user-defined handler */
1613
+ FREE_ZVAL (EG (user_exception_handler ));
1623
1614
EG (user_exception_handler ) = NULL ;
1624
1615
RETURN_TRUE ;
1625
1616
}
1617
+
1618
+ MAKE_COPY_ZVAL (& exception_handler , EG (user_exception_handler ))
1619
+
1620
+ if (!had_orig_exception_handler ) {
1621
+ RETURN_NULL ();
1622
+ }
1626
1623
}
1627
1624
/* }}} */
1628
1625
0 commit comments