version 1.1, 2012/02/21 23:48:02
|
version 1.1.1.4, 2014/06/15 20:03:57
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2014 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 12
|
Line 12
|
| obtain it through the world-wide-web, please send a note to | |
| obtain it through the world-wide-web, please send a note to | |
| license@php.net so we can mail you a copy immediately. | |
| license@php.net so we can mail you a copy immediately. | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Authors: Jani Lehtimäki <jkl@njet.net> | | | Authors: Jani Lehtimäki <jkl@njet.net> | |
| Thies C. Arntzen <thies@thieso.net> | |
| Thies C. Arntzen <thies@thieso.net> | |
| Sascha Schumann <sascha@schumann.cx> | |
| Sascha Schumann <sascha@schumann.cx> | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
Line 56 static int php_array_element_dump(zval **zv TSRMLS_DC,
|
Line 56 static int php_array_element_dump(zval **zv TSRMLS_DC,
|
static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
{ |
{ |
int level; |
int level; |
char *prop_name, *class_name; | const char *prop_name, *class_name; |
|
|
level = va_arg(args, int); |
level = va_arg(args, int); |
|
|
Line 87 static int php_object_property_dump(zval **zv TSRMLS_D
|
Line 87 static int php_object_property_dump(zval **zv TSRMLS_D
|
PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
{ |
{ |
HashTable *myht; |
HashTable *myht; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int is_temp; |
int is_temp; |
Line 133 PHPAPI void php_var_dump(zval **struc, int level TSRML
|
Line 133 PHPAPI void php_var_dump(zval **struc, int level TSRML
|
return; |
return; |
} |
} |
|
|
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); | if (Z_OBJ_HANDLER(**struc, get_class_name)) { |
php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); | Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); |
efree(class_name); | php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); |
| efree((char*)class_name); |
| } else { |
| php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0); |
| } |
php_element_dump_func = php_object_property_dump; |
php_element_dump_func = php_object_property_dump; |
head_done: |
head_done: |
if (myht) { |
if (myht) { |
Line 152 head_done:
|
Line 156 head_done:
|
PUTS("}\n"); |
PUTS("}\n"); |
break; |
break; |
case IS_RESOURCE: { |
case IS_RESOURCE: { |
char *type_name; | const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); |
| |
type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); | |
php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown"); |
php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown"); |
break; |
break; |
} |
} |
Line 211 static int zval_array_element_dump(zval **zv TSRMLS_DC
|
Line 213 static int zval_array_element_dump(zval **zv TSRMLS_DC
|
static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ |
{ |
{ |
int level; |
int level; |
char *prop_name, *class_name; | const char *prop_name, *class_name; |
|
|
level = va_arg(args, int); |
level = va_arg(args, int); |
|
|
Line 240 static int zval_object_property_dump(zval **zv TSRMLS_
|
Line 242 static int zval_object_property_dump(zval **zv TSRMLS_
|
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */ |
{ |
{ |
HashTable *myht = NULL; |
HashTable *myht = NULL; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*); |
int is_temp = 0; |
int is_temp = 0; |
Line 282 PHPAPI void php_debug_zval_dump(zval **struc, int leve
|
Line 284 PHPAPI void php_debug_zval_dump(zval **struc, int leve
|
PUTS("*RECURSION*\n"); |
PUTS("*RECURSION*\n"); |
return; |
return; |
} |
} |
if (Z_OBJ_HANDLER_PP(struc, get_class_name)) { | Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); |
Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC); | php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); |
php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); | efree((char*)class_name); |
efree(class_name); | |
} else { | |
php_printf("%sobject(unknown class)#%d (%d) refcount(%u){\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc)); | |
} | |
zval_element_dump_func = zval_object_property_dump; |
zval_element_dump_func = zval_object_property_dump; |
head_done: |
head_done: |
if (myht) { |
if (myht) { |
Line 304 head_done:
|
Line 302 head_done:
|
PUTS("}\n"); |
PUTS("}\n"); |
break; |
break; |
case IS_RESOURCE: { |
case IS_RESOURCE: { |
char *type_name; | const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); |
| |
type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC); | |
php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc)); |
php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc)); |
break; |
break; |
} |
} |
Line 357 static int php_array_element_export(zval **zv TSRMLS_D
|
Line 353 static int php_array_element_export(zval **zv TSRMLS_D
|
buffer_append_spaces(buf, level+1); |
buffer_append_spaces(buf, level+1); |
smart_str_append_long(buf, (long) hash_key->h); |
smart_str_append_long(buf, (long) hash_key->h); |
smart_str_appendl(buf, " => ", 4); |
smart_str_appendl(buf, " => ", 4); |
|
|
} else { /* string key */ |
} else { /* string key */ |
char *key, *tmp_str; |
char *key, *tmp_str; |
int key_len, tmp_len; |
int key_len, tmp_len; |
Line 376 static int php_array_element_export(zval **zv TSRMLS_D
|
Line 373 static int php_array_element_export(zval **zv TSRMLS_D
|
|
|
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
| |
return 0; |
return 0; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 391 static int php_object_element_export(zval **zv TSRMLS_
|
Line 388 static int php_object_element_export(zval **zv TSRMLS_
|
|
|
buffer_append_spaces(buf, level + 2); |
buffer_append_spaces(buf, level + 2); |
if (hash_key->nKeyLength != 0) { |
if (hash_key->nKeyLength != 0) { |
char *class_name, /* ignored, but must be passed to unmangle */ | const char *class_name; /* ignored, but must be passed to unmangle */ |
*pname, | const char *pname; |
*pname_esc; | char *pname_esc; |
int pname_esc_len; |
int pname_esc_len; |
|
|
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, |
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, |
Line 406 static int php_object_element_export(zval **zv TSRMLS_
|
Line 403 static int php_object_element_export(zval **zv TSRMLS_
|
smart_str_appendc(buf, '\''); |
smart_str_appendc(buf, '\''); |
efree(pname_esc); |
efree(pname_esc); |
} else { |
} else { |
smart_str_append_long(buf, hash_key->h); | smart_str_append_long(buf, (long) hash_key->h); |
} |
} |
|
|
smart_str_appendl(buf, " => ", 4); |
smart_str_appendl(buf, " => ", 4); |
php_var_export_ex(zv, level + 2, buf TSRMLS_CC); |
php_var_export_ex(zv, level + 2, buf TSRMLS_CC); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, ','); |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
|
|
return 0; |
return 0; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 423 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 418 PHPAPI void php_var_export_ex(zval **struc, int level,
|
HashTable *myht; |
HashTable *myht; |
char *tmp_str, *tmp_str2; |
char *tmp_str, *tmp_str2; |
int tmp_len, tmp_len2; |
int tmp_len, tmp_len2; |
char *class_name; | const char *class_name; |
zend_uint class_name_len; |
zend_uint class_name_len; |
|
|
switch (Z_TYPE_PP(struc)) { |
switch (Z_TYPE_PP(struc)) { |
case IS_BOOL: |
case IS_BOOL: |
if (Z_LVAL_PP(struc)) { | if (Z_LVAL_PP(struc)) { |
smart_str_appendl(buf, "true", 4); | smart_str_appendl(buf, "true", 4); |
} else { | } else { |
smart_str_appendl(buf, "false", 5); | smart_str_appendl(buf, "false", 5); |
} | } |
break; |
break; |
case IS_NULL: |
case IS_NULL: |
smart_str_appendl(buf, "NULL", 4); |
smart_str_appendl(buf, "NULL", 4); |
Line 441 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 436 PHPAPI void php_var_export_ex(zval **struc, int level,
|
smart_str_append_long(buf, Z_LVAL_PP(struc)); |
smart_str_append_long(buf, Z_LVAL_PP(struc)); |
break; |
break; |
case IS_DOUBLE: |
case IS_DOUBLE: |
tmp_len = spprintf(&tmp_str, 0,"%.*H", (int) EG(precision), Z_DVAL_PP(struc)); | tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_PP(struc)); |
smart_str_appendl(buf, tmp_str, tmp_len); |
smart_str_appendl(buf, tmp_str, tmp_len); |
efree(tmp_str); |
efree(tmp_str); |
break; |
break; |
Line 458 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 453 PHPAPI void php_var_export_ex(zval **struc, int level,
|
break; |
break; |
case IS_ARRAY: |
case IS_ARRAY: |
myht = Z_ARRVAL_PP(struc); |
myht = Z_ARRVAL_PP(struc); |
|
if(myht && myht->nApplyCount > 0){ |
|
smart_str_appendl(buf, "NULL", 4); |
|
zend_error(E_WARNING, "var_export does not handle circular references"); |
|
return; |
|
} |
if (level > 1) { |
if (level > 1) { |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
Line 469 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 469 PHPAPI void php_var_export_ex(zval **struc, int level,
|
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
} |
} |
smart_str_appendc(buf, ')'); |
smart_str_appendc(buf, ')'); |
| |
break; |
break; |
|
|
case IS_OBJECT: |
case IS_OBJECT: |
myht = Z_OBJPROP_PP(struc); |
myht = Z_OBJPROP_PP(struc); |
|
if(myht && myht->nApplyCount > 0){ |
|
smart_str_appendl(buf, "NULL", 4); |
|
zend_error(E_WARNING, "var_export does not handle circular references"); |
|
return; |
|
} |
if (level > 1) { |
if (level > 1) { |
smart_str_appendc(buf, '\n'); |
smart_str_appendc(buf, '\n'); |
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
Line 482 PHPAPI void php_var_export_ex(zval **struc, int level,
|
Line 488 PHPAPI void php_var_export_ex(zval **struc, int level,
|
smart_str_appendl(buf, class_name, class_name_len); |
smart_str_appendl(buf, class_name, class_name_len); |
smart_str_appendl(buf, "::__set_state(array(\n", 21); |
smart_str_appendl(buf, "::__set_state(array(\n", 21); |
|
|
efree(class_name); | efree((char*)class_name); |
if (myht) { |
if (myht) { |
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 2, level, buf); | zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 1, level, buf); |
} |
} |
if (level > 1) { |
if (level > 1) { |
buffer_append_spaces(buf, level - 1); |
buffer_append_spaces(buf, level - 1); |
Line 510 PHPAPI void php_var_export(zval **struc, int level TSR
|
Line 516 PHPAPI void php_var_export(zval **struc, int level TSR
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
|
/* {{{ proto mixed var_export(mixed var [, bool return]) |
/* {{{ proto mixed var_export(mixed var [, bool return]) |
Outputs or returns a string representation of a variable */ |
Outputs or returns a string representation of a variable */ |
PHP_FUNCTION(var_export) |
PHP_FUNCTION(var_export) |
Line 542 static inline int php_add_var_hash(HashTable *var_hash
|
Line 549 static inline int php_add_var_hash(HashTable *var_hash
|
char id[32], *p; |
char id[32], *p; |
register int len; |
register int len; |
|
|
/* relies on "(long)" being a perfect hash function for data pointers, |
|
* however the actual identity of an object has had to be determined |
|
* by its object handle and the class entry since 5.0. */ |
|
if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) { |
if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) { |
p = smart_str_print_long(id + sizeof(id) - 1, |
p = smart_str_print_long(id + sizeof(id) - 1, |
(((size_t)Z_OBJCE_P(var) << 5) | (long) zend_objects_get_address(var TSRMLS_CC)); |
| ((size_t)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5))) | |
+ (long) Z_OBJ_HANDLE_P(var)); | |
*(--p) = 'O'; |
*(--p) = 'O'; |
len = id + sizeof(id) - 1 - p; |
len = id + sizeof(id) - 1 - p; |
} else { |
} else { |
Line 564 static inline int php_add_var_hash(HashTable *var_hash
|
Line 566 static inline int php_add_var_hash(HashTable *var_hash
|
var_no = -1; |
var_no = -1; |
zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL); |
zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL); |
} |
} |
|
#if 0 |
|
fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old); |
|
#endif |
return FAILURE; |
return FAILURE; |
} |
} |
|
|
/* +1 because otherwise hash will think we are trying to store NULL pointer */ |
/* +1 because otherwise hash will think we are trying to store NULL pointer */ |
var_no = zend_hash_num_elements(var_hash) + 1; |
var_no = zend_hash_num_elements(var_hash) + 1; |
zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL); |
zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL); |
|
#if 0 |
|
fprintf(stderr, "+ add var (%d): %lu\n", Z_TYPE_P(var), var_no); |
|
#endif |
return SUCCESS; |
return SUCCESS; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 629 static void php_var_serialize_class(smart_str *buf, zv
|
Line 637 static void php_var_serialize_class(smart_str *buf, zv
|
HashPosition pos; |
HashPosition pos; |
int i; |
int i; |
zval nval, *nvalp; |
zval nval, *nvalp; |
|
HashTable *propers; |
|
|
ZVAL_NULL(&nval); |
ZVAL_NULL(&nval); |
nvalp = &nval; |
nvalp = &nval; |
Line 654 static void php_var_serialize_class(smart_str *buf, zv
|
Line 663 static void php_var_serialize_class(smart_str *buf, zv
|
smart_str_appendl(buf,"N;", 2); |
smart_str_appendl(buf,"N;", 2); |
continue; |
continue; |
} |
} |
if (zend_hash_find(Z_OBJPROP_P(struc), Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) { | propers = Z_OBJPROP_P(struc); |
| if (zend_hash_find(propers, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) { |
php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); |
php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
} else { |
} else { |
Line 666 static void php_var_serialize_class(smart_str *buf, zv
|
Line 676 static void php_var_serialize_class(smart_str *buf, zv
|
|
|
do { |
do { |
zend_mangle_property_name(&priv_name, &prop_name_length, ce->name, ce->name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); |
zend_mangle_property_name(&priv_name, &prop_name_length, ce->name, ce->name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); |
if (zend_hash_find(Z_OBJPROP_P(struc), priv_name, prop_name_length + 1, (void *) &d) == SUCCESS) { | if (zend_hash_find(propers, priv_name, prop_name_length + 1, (void *) &d) == SUCCESS) { |
php_var_serialize_string(buf, priv_name, prop_name_length); |
php_var_serialize_string(buf, priv_name, prop_name_length); |
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS); |
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
Line 674 static void php_var_serialize_class(smart_str *buf, zv
|
Line 684 static void php_var_serialize_class(smart_str *buf, zv
|
} |
} |
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS); |
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS); |
zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); |
zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); |
if (zend_hash_find(Z_OBJPROP_P(struc), prot_name, prop_name_length + 1, (void *) &d) == SUCCESS) { | if (zend_hash_find(propers, prot_name, prop_name_length + 1, (void *) &d) == SUCCESS) { |
php_var_serialize_string(buf, prot_name, prop_name_length); |
php_var_serialize_string(buf, prot_name, prop_name_length); |
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS); |
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); |
Line 702 static void php_var_serialize_intern(smart_str *buf, z
|
Line 712 static void php_var_serialize_intern(smart_str *buf, z
|
ulong *var_already; |
ulong *var_already; |
HashTable *myht; |
HashTable *myht; |
|
|
|
if (EG(exception)) { |
|
return; |
|
} |
|
|
if (var_hash && php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) { |
if (var_hash && php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) { |
if (Z_ISREF_P(struc)) { |
if (Z_ISREF_P(struc)) { |
smart_str_appendl(buf, "R:", 2); |
smart_str_appendl(buf, "R:", 2); |
Line 785 static void php_var_serialize_intern(smart_str *buf, z
|
Line 799 static void php_var_serialize_intern(smart_str *buf, z
|
if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { |
if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { |
INIT_PZVAL(&fname); |
INIT_PZVAL(&fname); |
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); |
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); |
|
BG(serialize_lock)++; |
res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); |
|
BG(serialize_lock)--; |
|
|
|
if (EG(exception)) { |
|
if (retval_ptr) { |
|
zval_ptr_dtor(&retval_ptr); |
|
} |
|
return; |
|
} |
|
|
if (res == SUCCESS && !EG(exception)) { | if (res == SUCCESS) { |
if (retval_ptr) { |
if (retval_ptr) { |
if (HASH_OF(retval_ptr)) { |
if (HASH_OF(retval_ptr)) { |
php_var_serialize_class(buf, struc, retval_ptr, var_hash TSRMLS_CC); |
php_var_serialize_class(buf, struc, retval_ptr, var_hash TSRMLS_CC); |
Line 880 static void php_var_serialize_intern(smart_str *buf, z
|
Line 903 static void php_var_serialize_intern(smart_str *buf, z
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC) /* {{{ */ | PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC) /* {{{ */ |
{ |
{ |
php_var_serialize_intern(buf, *struc, var_hash TSRMLS_CC); | php_var_serialize_intern(buf, *struc, *var_hash TSRMLS_CC); |
smart_str_0(buf); |
smart_str_0(buf); |
} |
} |
/* }}} */ |
/* }}} */ |
Line 907 PHP_FUNCTION(serialize)
|
Line 930 PHP_FUNCTION(serialize)
|
php_var_serialize(&buf, struc, &var_hash TSRMLS_CC); |
php_var_serialize(&buf, struc, &var_hash TSRMLS_CC); |
PHP_VAR_SERIALIZE_DESTROY(var_hash); |
PHP_VAR_SERIALIZE_DESTROY(var_hash); |
|
|
|
if (EG(exception)) { |
|
smart_str_free(&buf); |
|
RETURN_FALSE; |
|
} |
|
|
if (buf.c) { |
if (buf.c) { |
RETURN_STRINGL(buf.c, buf.len, 0); |
RETURN_STRINGL(buf.c, buf.len, 0); |
} else { |
} else { |
Line 937 PHP_FUNCTION(unserialize)
|
Line 965 PHP_FUNCTION(unserialize)
|
if (!php_var_unserialize(&return_value, &p, p + buf_len, &var_hash TSRMLS_CC)) { |
if (!php_var_unserialize(&return_value, &p, p + buf_len, &var_hash TSRMLS_CC)) { |
PHP_VAR_UNSERIALIZE_DESTROY(var_hash); |
PHP_VAR_UNSERIALIZE_DESTROY(var_hash); |
zval_dtor(return_value); |
zval_dtor(return_value); |
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len); | if (!EG(exception)) { |
| php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len); |
| } |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
PHP_VAR_UNSERIALIZE_DESTROY(var_hash); |
PHP_VAR_UNSERIALIZE_DESTROY(var_hash); |