@@ -1664,14 +1664,10 @@ PHP_FUNCTION(forward_static_call_array)
1664
1664
1665
1665
void user_shutdown_function_dtor (zval * zv ) /* {{{ */
1666
1666
{
1667
- int i ;
1668
1667
php_shutdown_function_entry * shutdown_function_entry = Z_PTR_P (zv );
1669
1668
1670
- zval_ptr_dtor (& shutdown_function_entry -> function_name );
1671
- for (i = 0 ; i < shutdown_function_entry -> arg_count ; i ++ ) {
1672
- zval_ptr_dtor (& shutdown_function_entry -> arguments [i ]);
1673
- }
1674
- efree (shutdown_function_entry -> arguments );
1669
+ zval_ptr_dtor (& shutdown_function_entry -> fci .function_name );
1670
+ zend_fcall_info_args_clear (& shutdown_function_entry -> fci , true);
1675
1671
efree (shutdown_function_entry );
1676
1672
}
1677
1673
/* }}} */
@@ -1685,24 +1681,16 @@ void user_tick_function_dtor(user_tick_function_entry *tick_function_entry) /* {
1685
1681
1686
1682
static int user_shutdown_function_call (zval * zv ) /* {{{ */
1687
1683
{
1688
- php_shutdown_function_entry * shutdown_function_entry = Z_PTR_P (zv );
1684
+ php_shutdown_function_entry * shutdown_function_entry = Z_PTR_P (zv );
1689
1685
zval retval ;
1686
+ zend_result call_status ;
1690
1687
1691
- if (!zend_is_callable (& shutdown_function_entry -> function_name , 0 , NULL )) {
1692
- zend_string * function_name = zend_get_callable_name (& shutdown_function_entry -> function_name );
1693
- zend_throw_error (NULL , "Registered shutdown function %s() cannot be called, function does not exist" , ZSTR_VAL (function_name ));
1694
- zend_string_release (function_name );
1695
- return 0 ;
1696
- }
1688
+ /* set retval zval for FCI struct */
1689
+ shutdown_function_entry -> fci .retval = & retval ;
1690
+ call_status = zend_call_function (& shutdown_function_entry -> fci , & shutdown_function_entry -> fci_cache );
1691
+ ZEND_ASSERT (call_status == SUCCESS );
1692
+ zval_ptr_dtor (& retval );
1697
1693
1698
- if (call_user_function (NULL , NULL ,
1699
- & shutdown_function_entry -> function_name ,
1700
- & retval ,
1701
- shutdown_function_entry -> arg_count ,
1702
- shutdown_function_entry -> arguments ) == SUCCESS )
1703
- {
1704
- zval_ptr_dtor (& retval );
1705
- }
1706
1694
return 0 ;
1707
1695
}
1708
1696
/* }}} */
@@ -1761,8 +1749,7 @@ PHPAPI void php_call_shutdown_functions(void) /* {{{ */
1761
1749
if (BG (user_shutdown_function_names )) {
1762
1750
zend_try {
1763
1751
zend_hash_apply (BG (user_shutdown_function_names ), user_shutdown_function_call );
1764
- }
1765
- zend_end_try ();
1752
+ } zend_end_try ();
1766
1753
}
1767
1754
}
1768
1755
/* }}} */
@@ -1786,23 +1773,19 @@ PHPAPI void php_free_shutdown_functions(void) /* {{{ */
1786
1773
PHP_FUNCTION (register_shutdown_function )
1787
1774
{
1788
1775
php_shutdown_function_entry entry ;
1789
- zend_fcall_info fci ;
1790
- zend_fcall_info_cache fcc ;
1791
- zval * args ;
1792
- int arg_count = 0 ;
1776
+ zval * params = NULL ;
1777
+ uint32_t param_count = 0 ;
1778
+ bool status ;
1793
1779
1794
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "f*" , & fci , & fcc , & args , & arg_count ) == FAILURE ) {
1780
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "f*" , & entry . fci , & entry . fci_cache , & params , & param_count ) == FAILURE ) {
1795
1781
RETURN_THROWS ();
1796
1782
}
1797
1783
1798
- ZVAL_COPY (& entry .function_name , & fci .function_name );
1799
- entry .arguments = (zval * ) safe_emalloc (sizeof (zval ), arg_count , 0 );
1800
- entry .arg_count = arg_count ;
1801
- for (int i = 0 ; i < arg_count ; i ++ ) {
1802
- ZVAL_COPY (& entry .arguments [i ], & args [i ]);
1803
- }
1784
+ Z_TRY_ADDREF (entry .fci .function_name );
1785
+ zend_fcall_info_argp (& entry .fci , param_count , params );
1804
1786
1805
- append_user_shutdown_function (& entry );
1787
+ status = append_user_shutdown_function (& entry );
1788
+ ZEND_ASSERT (status );
1806
1789
}
1807
1790
/* }}} */
1808
1791
0 commit comments