version 1.1.1.2, 2012/05/29 12:34:43
|
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 436 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 453 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 474 PHPAPI void php_var_export_ex(zval **struc, int level,
|
|
|
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 539 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 632 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 657 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 669 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 677 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 705 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 791 static void php_var_serialize_intern(smart_str *buf, z
|
Line 802 static void php_var_serialize_intern(smart_str *buf, z
|
BG(serialize_lock)++; |
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)--; |
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 912 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 942 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); |