summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2005-06-27 18:13:13 +0000
committerStanislav Malyshev <stas@php.net>2005-06-27 18:13:13 +0000
commitd5a129600895cdd0cba0b8834cb9951863c6999b (patch)
treef662205cd0df0955321c56ffd519ad4070022d69 /Zend/zend_API.c
parent46fcf913b29394d44a4918b224d427a19ba00a72 (diff)
downloadphp-git-d5a129600895cdd0cba0b8834cb9951863c6999b.tar.gz
fix various "Class entry requested for an object without PHP class" messages
when working with non-PHP objects. # Using Z_OBJCE(object)->name is usually bad idea unless you know it's # a pure PHP object
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index c6ca975cfe..691c931335 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -156,11 +156,19 @@ ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_arr
if (EG(ze1_compatibility_mode) && Z_TYPE_PP(value) == IS_OBJECT) {
zval *value_ptr;
+ char *class_name;
+ zend_uint class_name_len;
+ int dup;
+
+ dup = zend_get_object_classname(*value, &class_name, &class_name_len TSRMLS_CC);
ALLOC_ZVAL(value_ptr);
*value_ptr = **value;
INIT_PZVAL(value_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_PP(value)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
+ if(!dup) {
+ efree(class_name);
+ }
value_ptr->value.obj = Z_OBJ_HANDLER_PP(value, clone_obj)(*value TSRMLS_CC);
zval_ptr_dtor(value);
*value = value_ptr;
@@ -248,6 +256,19 @@ ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC)
}
}
+ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC)
+{
+ if (Z_OBJ_HT_P(object)->get_class_name == NULL ||
+ Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {
+ zend_class_entry *ce = Z_OBJCE_P(object);
+
+ *class_name = ce->name;
+ *class_name_len = ce->name_length;
+ return 1;
+ }
+ return 0;
+}
+
static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec TSRMLS_DC)
{
@@ -2197,7 +2218,12 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->write_property) {
- zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", Z_OBJCE_P(object)->name, name);
+ char *class_name;
+ zend_uint class_name_len;
+
+ zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
+
+ zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, class_name);
}
ZVAL_STRINGL(&property, name, name_length, 0);
Z_OBJ_HT_P(object)->write_property(object, &property, value TSRMLS_CC);
@@ -2279,7 +2305,11 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *n
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->read_property) {
- zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", Z_OBJCE_P(object)->name, name);
+ char *class_name;
+ zend_uint class_name_len;
+
+ zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
+ zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", name, class_name);
}
ZVAL_STRINGL(&property, name, name_length, 0);
value = Z_OBJ_HT_P(object)->read_property(object, &property, silent TSRMLS_CC);