@@ -722,28 +722,36 @@ static inline bool php_var_serialize_class_name(smart_str *buf, zval *struc) /*
722
722
}
723
723
/* }}} */
724
724
725
- static int php_var_serialize_call_sleep (zval * retval , zval * struc ) /* {{{ */
725
+ static zend_result php_var_serialize_call_sleep (zend_object * obj , zend_function * fn , zval * retval ) /* {{{ */
726
726
{
727
- zval fname ;
728
- int res ;
727
+ zend_result res ;
728
+ zend_fcall_info fci ;
729
+ zend_fcall_info_cache fci_cache ;
730
+
731
+ fci .size = sizeof (fci );
732
+ fci .object = obj ;
733
+ fci .retval = retval ;
734
+ fci .param_count = 0 ;
735
+ fci .params = NULL ;
736
+ fci .named_params = NULL ;
737
+ ZVAL_UNDEF (& fci .function_name );
738
+
739
+ fci_cache .function_handler = fn ;
740
+ fci_cache .object = obj ;
741
+ fci_cache .called_scope = obj -> ce ;
729
742
730
- ZVAL_STRINGL (& fname , "__sleep" , sizeof ("__sleep" ) - 1 );
731
743
BG (serialize_lock )++ ;
732
- res = call_user_function ( NULL , struc , & fname , retval , 0 , 0 );
744
+ res = zend_call_function ( & fci , & fci_cache );
733
745
BG (serialize_lock )-- ;
734
- zval_ptr_dtor_str (& fname );
735
746
736
747
if (res == FAILURE || Z_ISUNDEF_P (retval )) {
737
748
zval_ptr_dtor (retval );
738
749
return FAILURE ;
739
750
}
740
751
741
752
if (!HASH_OF (retval )) {
742
- zend_class_entry * ce ;
743
- ZEND_ASSERT (Z_TYPE_P (struc ) == IS_OBJECT );
744
- ce = Z_OBJCE_P (struc );
745
753
zval_ptr_dtor (retval );
746
- php_error_docref (NULL , E_WARNING , "%s::__sleep() should return an array only containing the names of instance-variables to serialize" , ZSTR_VAL (ce -> name ));
754
+ php_error_docref (NULL , E_WARNING , "%s::__sleep() should return an array only containing the names of instance-variables to serialize" , ZSTR_VAL (obj -> ce -> name ));
747
755
return FAILURE ;
748
756
}
749
757
@@ -1067,25 +1075,28 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
1067
1075
return ;
1068
1076
}
1069
1077
1070
- if (ce != PHP_IC_ENTRY && zend_hash_str_exists (& ce -> function_table , "__sleep" , sizeof ("__sleep" )- 1 )) {
1071
- zval retval , tmp ;
1072
-
1073
- ZVAL_OBJ_COPY (& tmp , Z_OBJ_P (struc ));
1074
-
1075
- if (php_var_serialize_call_sleep (& retval , & tmp ) == FAILURE ) {
1076
- if (!EG (exception )) {
1077
- /* we should still add element even if it's not OK,
1078
- * since we already wrote the length of the array before */
1079
- smart_str_appendl (buf , "N;" , 2 );
1078
+ if (ce != PHP_IC_ENTRY ) {
1079
+ zval * zv = zend_hash_find_ex (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_SLEEP ), 1 );
1080
+
1081
+ if (zv ) {
1082
+ zval retval , tmp ;
1083
+
1084
+ ZVAL_OBJ_COPY (& tmp , Z_OBJ_P (struc ));
1085
+ if (php_var_serialize_call_sleep (Z_OBJ (tmp ), Z_FUNC_P (zv ), & retval ) == FAILURE ) {
1086
+ if (!EG (exception )) {
1087
+ /* we should still add element even if it's not OK,
1088
+ * since we already wrote the length of the array before */
1089
+ smart_str_appendl (buf , "N;" , 2 );
1090
+ }
1091
+ OBJ_RELEASE (Z_OBJ (tmp ));
1092
+ return ;
1080
1093
}
1081
- zval_ptr_dtor (& tmp );
1094
+
1095
+ php_var_serialize_class (buf , & tmp , & retval , var_hash );
1096
+ zval_ptr_dtor (& retval );
1097
+ OBJ_RELEASE (Z_OBJ (tmp ));
1082
1098
return ;
1083
1099
}
1084
-
1085
- php_var_serialize_class (buf , & tmp , & retval , var_hash );
1086
- zval_ptr_dtor (& retval );
1087
- zval_ptr_dtor (& tmp );
1088
- return ;
1089
1100
}
1090
1101
1091
1102
incomplete_class = php_var_serialize_class_name (buf , struc );
0 commit comments