mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Accept zend_object in zend_read_property
This commit is contained in:
parent
0400d07e61
commit
7991fc2753
@ -4179,21 +4179,21 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
|
||||
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
|
||||
{
|
||||
zval *value;
|
||||
zend_class_entry *old_scope = EG(fake_scope);
|
||||
|
||||
EG(fake_scope) = scope;
|
||||
|
||||
value = Z_OBJ_HT_P(object)->read_property(Z_OBJ_P(object), name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
|
||||
value = object->handlers->read_property(object, name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
|
||||
|
||||
EG(fake_scope) = old_scope;
|
||||
return value;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
|
||||
ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
|
||||
{
|
||||
zval *value;
|
||||
zend_string *str;
|
||||
|
@ -400,8 +400,8 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c
|
||||
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
|
||||
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length);
|
||||
|
||||
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv);
|
||||
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
|
||||
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv);
|
||||
ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
|
||||
|
||||
ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, zend_bool silent);
|
||||
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
|
||||
|
@ -99,16 +99,16 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
|
||||
ZVAL_OBJ(&zv, exception);
|
||||
ex = &zv;
|
||||
do {
|
||||
ancestor = zend_read_property_ex(i_get_exception_base(&pv), &pv, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
ancestor = zend_read_property_ex(i_get_exception_base(&pv), Z_OBJ(pv), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
while (Z_TYPE_P(ancestor) == IS_OBJECT) {
|
||||
if (Z_OBJ_P(ancestor) == Z_OBJ_P(ex)) {
|
||||
OBJ_RELEASE(add_previous);
|
||||
return;
|
||||
}
|
||||
ancestor = zend_read_property_ex(i_get_exception_base(ancestor), ancestor, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
ancestor = zend_read_property_ex(i_get_exception_base(ancestor), Z_OBJ_P(ancestor), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
}
|
||||
base_ce = i_get_exception_base(ex);
|
||||
previous = zend_read_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
previous = zend_read_property_ex(base_ce, Z_OBJ_P(ex), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
|
||||
if (Z_TYPE_P(previous) == IS_NULL) {
|
||||
zend_update_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), &pv);
|
||||
GC_DELREF(add_previous);
|
||||
@ -309,7 +309,7 @@ ZEND_METHOD(Exception, __construct)
|
||||
|
||||
/* {{{ Exception unserialize checks */
|
||||
#define CHECK_EXC_TYPE(id, type) \
|
||||
pvalue = zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &value); \
|
||||
pvalue = zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &value); \
|
||||
if (Z_TYPE_P(pvalue) != IS_NULL && Z_TYPE_P(pvalue) != type) { \
|
||||
zend_unset_property(i_get_exception_base(object), object, ZSTR_VAL(ZSTR_KNOWN(id)), ZSTR_LEN(ZSTR_KNOWN(id))); \
|
||||
}
|
||||
@ -375,9 +375,9 @@ ZEND_METHOD(ErrorException, __construct)
|
||||
/* }}} */
|
||||
|
||||
#define GET_PROPERTY(object, id) \
|
||||
zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 0, &rv)
|
||||
zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv)
|
||||
#define GET_PROPERTY_SILENT(object, id) \
|
||||
zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &rv)
|
||||
zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv)
|
||||
|
||||
/* {{{ Get the file in which the exception occurred */
|
||||
ZEND_METHOD(Exception, getFile)
|
||||
@ -603,7 +603,7 @@ ZEND_METHOD(Exception, getTraceAsString)
|
||||
object = ZEND_THIS;
|
||||
base_ce = i_get_exception_base(object);
|
||||
|
||||
trace = zend_read_property_ex(base_ce, object, ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
|
||||
trace = zend_read_property_ex(base_ce, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
|
||||
* and expose it as a COM exception */
|
||||
|
||||
if (wFlags & DISPATCH_PROPERTYGET) {
|
||||
retval = zend_read_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
|
||||
retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
|
||||
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
||||
zend_update_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name), ¶ms[0]);
|
||||
} else if (wFlags & DISPATCH_METHOD) {
|
||||
|
@ -71,7 +71,7 @@ static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION
|
||||
zval *res, rv;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
res = zend_read_property(curl_CURLFile_class, ZEND_THIS, name, name_len, 1, &rv);
|
||||
res = zend_read_property(curl_CURLFile_class, Z_OBJ_P(ZEND_THIS), name, name_len, 1, &rv);
|
||||
ZVAL_COPY_DEREF(return_value, res);
|
||||
}
|
||||
|
||||
|
@ -2047,7 +2047,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
|
||||
curl_seek_callback seekfunc = seek_cb;
|
||||
#endif
|
||||
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
|
||||
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "name", sizeof("name")-1, 0, &rv);
|
||||
if (Z_TYPE_P(prop) != IS_STRING) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
|
||||
} else {
|
||||
@ -2057,11 +2057,11 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
|
||||
return 1;
|
||||
}
|
||||
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0, &rv);
|
||||
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
|
||||
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
||||
type = Z_STRVAL_P(prop);
|
||||
}
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
|
||||
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "postname", sizeof("postname")-1, 0, &rv);
|
||||
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
||||
filename = Z_STRVAL_P(prop);
|
||||
}
|
||||
|
@ -1539,11 +1539,8 @@ static int dom_nodelist_has_dimension(zend_object *object, zval *member, int che
|
||||
if (offset < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
zval obj;
|
||||
zval *length;
|
||||
|
||||
ZVAL_OBJ(&obj, object);
|
||||
length = zend_read_property(object->ce, &obj, "length", sizeof("length") - 1, 0, &rv);
|
||||
zval *length = zend_read_property(
|
||||
object->ce, object, "length", sizeof("length") - 1, 0, &rv);
|
||||
return length && offset < Z_LVAL_P(length);
|
||||
}
|
||||
} /* }}} end dom_nodelist_has_dimension */
|
||||
|
@ -5316,7 +5316,7 @@ ZEND_METHOD(ReflectionProperty, getValue)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
|
||||
member_p = zend_read_property_ex(intern->ce, Z_OBJ_P(object), ref->unmangled_name, 0, &rv);
|
||||
if (member_p != &rv) {
|
||||
ZVAL_COPY_DEREF(return_value, member_p);
|
||||
} else {
|
||||
|
@ -1170,7 +1170,7 @@ static void set_zval_property(zval* object, char* name, zval* val)
|
||||
static zval* get_zval_property(zval* object, char* name, zval *rv)
|
||||
{
|
||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||
zval *data = zend_read_property(Z_OBJCE_P(object), object, name, strlen(name), 1, rv);
|
||||
zval *data = zend_read_property(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
|
||||
if (data == &EG(uninitialized_zval)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -643,10 +643,10 @@ PHP_METHOD(SoapFault, __toString)
|
||||
}
|
||||
|
||||
this_ptr = ZEND_THIS;
|
||||
faultcode = zend_read_property(soap_fault_class_entry, this_ptr, "faultcode", sizeof("faultcode")-1, 1, &rv1);
|
||||
faultstring = zend_read_property(soap_fault_class_entry, this_ptr, "faultstring", sizeof("faultstring")-1, 1, &rv2);
|
||||
file = zend_read_property(soap_fault_class_entry, this_ptr, "file", sizeof("file")-1, 1, &rv3);
|
||||
line = zend_read_property(soap_fault_class_entry, this_ptr, "line", sizeof("line")-1, 1, &rv4);
|
||||
faultcode = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultcode", sizeof("faultcode")-1, 1, &rv1);
|
||||
faultstring = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultstring", sizeof("faultstring")-1, 1, &rv2);
|
||||
file = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "file", sizeof("file")-1, 1, &rv3);
|
||||
line = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "line", sizeof("line")-1, 1, &rv4);
|
||||
|
||||
zend_call_method_with_0_params(
|
||||
Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), NULL, "gettraceasstring", &trace);
|
||||
@ -1176,7 +1176,7 @@ static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr functi
|
||||
} else if (instanceof_function(Z_OBJCE(exception_object), zend_ce_error)) {
|
||||
if (service->send_errors) {
|
||||
zval rv;
|
||||
zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
|
||||
zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
|
||||
add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
|
||||
zend_string_release_ex(msg, 0);
|
||||
} else {
|
||||
@ -2241,7 +2241,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
|
||||
zval exception_object;
|
||||
|
||||
ZVAL_OBJ(&exception_object, EG(exception));
|
||||
msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
|
||||
msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
|
||||
/* change class */
|
||||
EG(exception)->ce = soap_fault_class_entry;
|
||||
set_soap_fault(&exception_object, NULL, "Client", ZSTR_VAL(msg), NULL, NULL, NULL);
|
||||
|
@ -99,7 +99,7 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) {
|
||||
zval obj_zv, rv, *trace;
|
||||
|
||||
ZVAL_OBJ(&obj_zv, obj);
|
||||
trace = zend_read_property(zend_get_exception_base(&obj_zv), &obj_zv, "trace", sizeof("trace")-1, 0, &rv);
|
||||
trace = zend_read_property(zend_get_exception_base(&obj_zv), Z_OBJ(obj_zv), "trace", sizeof("trace")-1, 0, &rv);
|
||||
if (trace && Z_TYPE_P(trace) == IS_ARRAY) {
|
||||
zval *frame;
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) {
|
||||
|
@ -1863,7 +1863,7 @@ PHP_METHOD(RegexIterator, accept)
|
||||
break;
|
||||
|
||||
case REGIT_MODE_REPLACE: {
|
||||
zval *replacement = zend_read_property(intern->std.ce, ZEND_THIS, "replacement", sizeof("replacement")-1, 1, &rv);
|
||||
zval *replacement = zend_read_property(intern->std.ce, Z_OBJ_P(ZEND_THIS), "replacement", sizeof("replacement")-1, 1, &rv);
|
||||
zend_string *replacement_str = zval_try_get_string(replacement);
|
||||
if (UNEXPECTED(!replacement_str)) {
|
||||
return;
|
||||
|
@ -1067,12 +1067,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
|
||||
pce->constructor, Z_OBJ(ref), NULL, &arg);
|
||||
|
||||
if (EG(exception)) {
|
||||
zval tmp, *msg, rv;
|
||||
|
||||
ZVAL_OBJ(&tmp, EG(exception));
|
||||
msg = zend_read_property(zend_ce_exception, &tmp, "message", sizeof("message")-1, 0, &rv);
|
||||
zval rv;
|
||||
zval *msg = zend_read_property(zend_ce_exception, EG(exception), "message", sizeof("message")-1, 0, &rv);
|
||||
zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
|
||||
zval_ptr_dtor(&tmp);
|
||||
zend_object_release(EG(exception));
|
||||
EG(exception) = NULL;
|
||||
} else {
|
||||
zend_print_zval(&ref, 0);
|
||||
|
@ -726,8 +726,8 @@ static inline void phpdbg_handle_exception(void) /* {{{ */
|
||||
|
||||
ZVAL_OBJ(&zv, ex);
|
||||
zend_call_known_instance_method_with_0_params(ex->ce->__tostring, ex, &tmp);
|
||||
file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv));
|
||||
line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv));
|
||||
file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("file"), 1, &rv));
|
||||
line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("line"), 1, &rv));
|
||||
|
||||
if (EG(exception)) {
|
||||
EG(exception) = NULL;
|
||||
@ -735,7 +735,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */
|
||||
} else {
|
||||
zend_update_property_string(zend_get_exception_base(&zv), &zv, ZEND_STRL("string"), Z_STRVAL(tmp));
|
||||
zval_ptr_dtor(&tmp);
|
||||
msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("string"), 1, &rv));
|
||||
msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("string"), 1, &rv));
|
||||
}
|
||||
|
||||
phpdbg_error("exception", "name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"", "Uncaught %s in %s on line " ZEND_LONG_FMT, ZSTR_VAL(ex->ce->name), ZSTR_VAL(file), line);
|
||||
@ -1740,9 +1740,9 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
|
||||
PHPDBG_G(handled_exception) = exception;
|
||||
|
||||
ZVAL_OBJ(&zv, exception);
|
||||
file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv));
|
||||
line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv));
|
||||
msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("message"), 1, &rv));
|
||||
file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("file"), 1, &rv));
|
||||
line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("line"), 1, &rv));
|
||||
msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), Z_OBJ(zv), ZEND_STRL("message"), 1, &rv));
|
||||
|
||||
phpdbg_error("exception",
|
||||
"name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"",
|
||||
|
Loading…
Reference in New Issue
Block a user