diff options
-rw-r--r-- | ext/standard/php_incomplete_class.h | 18 | ||||
-rw-r--r-- | ext/standard/var.c | 16 |
2 files changed, 20 insertions, 14 deletions
diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h index 8c7f68ae15..bfcd6f6a32 100644 --- a/ext/standard/php_incomplete_class.h +++ b/ext/standard/php_incomplete_class.h @@ -26,18 +26,18 @@ #define PHP_IC_ENTRY \ BG(incomplete_class) -#define PHP_SET_CLASS_ATTRIBUTES(struc) \ - /* OBJECTS_FIXME: Fix for new object model */ \ - if (Z_OBJCE_P(struc) == BG(incomplete_class)) { \ - class_name = php_lookup_class_name(struc, &name_len); \ - free_class_name = 1; \ +#define PHP_SET_CLASS_ATTRIBUTES(struc) \ + /* OBJECTS_FIXME: Fix for new object model */ \ + if (Z_OBJ_HT_P(struc)->get_class_entry && \ + Z_OBJCE_P(struc) == BG(incomplete_class)) { \ + class_name = php_lookup_class_name(struc, &name_len); \ + free_class_name = 1; \ incomplete_class = 1; \ - } else { \ - class_name = Z_OBJCE_P(struc)->name; \ - name_len = Z_OBJCE_P(struc)->name_length; \ + } else { \ + free_class_name = !zend_get_object_classname(struc, &class_name, &name_len);\ } -#define PHP_CLEANUP_CLASS_ATTRIBUTES() \ +#define PHP_CLEANUP_CLASS_ATTRIBUTES() \ if (free_class_name) efree(class_name) #define PHP_CLASS_ATTRIBUTES \ diff --git a/ext/standard/var.c b/ext/standard/var.c index e4f68f37e2..1343802143 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -21,6 +21,7 @@ /* $Id$ */ + /* {{{ includes */ @@ -463,7 +464,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old /* 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) { + if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) { p = smart_str_print_long(id + sizeof(id) - 1, (((unsigned long)Z_OBJCE_P(var) << 5) | ((unsigned long)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5))) @@ -670,13 +671,18 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va zval *retval_ptr = NULL; zval fname; int res; + zend_class_entry *ce = NULL; + + if(Z_OBJ_HT_PP(struc)->get_class_entry) { + ce = Z_OBJCE_PP(struc); + } - if(Z_OBJCE_PP(struc)->serialize != NULL) { + if(ce && ce->serialize != NULL) { /* has custom handler */ unsigned char *serialized_data = NULL; zend_uint serialized_length; - if(Z_OBJCE_PP(struc)->serialize(*struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { + if(ce->serialize(*struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { smart_str_appendl(buf, "C:", 2); smart_str_append_long(buf, Z_OBJCE_PP(struc)->name_length); smart_str_appendl(buf, ":\"", 2); @@ -696,8 +702,8 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va return; } - if (Z_OBJCE_PP(struc) != PHP_IC_ENTRY && - zend_hash_exists(&Z_OBJCE_PP(struc)->function_table, "__sleep", sizeof("__sleep"))) { + if (ce && ce != PHP_IC_ENTRY && + zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { INIT_PZVAL(&fname); ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); res = call_user_function_ex(CG(function_table), struc, &fname, |