@@ -1158,6 +1158,57 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
1158
1158
}
1159
1159
1160
1160
incomplete_class = php_var_serialize_class_name (buf , struc );
1161
+
1162
+ if (Z_OBJ_P (struc )-> properties == NULL
1163
+ && Z_OBJ_HT_P (struc )-> get_properties_for == NULL
1164
+ && Z_OBJ_HT_P (struc )-> get_properties == zend_std_get_properties ) {
1165
+ /* Optimized version without rebulding properties HashTable */
1166
+ zend_object * obj = Z_OBJ_P (struc );
1167
+ zend_class_entry * ce = obj -> ce ;
1168
+ zend_property_info * prop_info ;
1169
+ zval * prop ;
1170
+ int i ;
1171
+
1172
+ count = ce -> default_properties_count ;
1173
+ for (i = 0 ; i < ce -> default_properties_count ; i ++ ) {
1174
+ prop_info = ce -> properties_info_table [i ];
1175
+ if (!prop_info ) {
1176
+ count -- ;
1177
+ continue ;
1178
+ }
1179
+ prop = OBJ_PROP (obj , prop_info -> offset );
1180
+ if (Z_TYPE_P (prop ) == IS_UNDEF ) {
1181
+ count -- ;
1182
+ continue ;
1183
+ }
1184
+ }
1185
+ if (count ) {
1186
+ smart_str_append_unsigned (buf , count );
1187
+ smart_str_appendl (buf , ":{" , 2 );
1188
+ for (i = 0 ; i < ce -> default_properties_count ; i ++ ) {
1189
+ prop_info = ce -> properties_info_table [i ];
1190
+ if (!prop_info ) {
1191
+ continue ;
1192
+ }
1193
+ prop = OBJ_PROP (obj , prop_info -> offset );
1194
+ if (Z_TYPE_P (prop ) == IS_UNDEF ) {
1195
+ continue ;
1196
+ }
1197
+
1198
+ php_var_serialize_string (buf , ZSTR_VAL (prop_info -> name ), ZSTR_LEN (prop_info -> name ));
1199
+
1200
+ if (Z_ISREF_P (prop ) && Z_REFCOUNT_P (prop ) == 1 ) {
1201
+ prop = Z_REFVAL_P (prop );
1202
+ }
1203
+
1204
+ php_var_serialize_intern (buf , prop , var_hash );
1205
+ }
1206
+ smart_str_appendc (buf , '}' );
1207
+ } else {
1208
+ smart_str_appendl (buf , "0:{}" , 4 );
1209
+ }
1210
+ return ;
1211
+ }
1161
1212
myht = zend_get_properties_for (struc , ZEND_PROP_PURPOSE_SERIALIZE );
1162
1213
/* count after serializing name, since php_var_serialize_class_name
1163
1214
* changes the count if the variable is incomplete class */
0 commit comments