Skip to content

Commit 7991fc2

Browse files
committed
Accept zend_object in zend_read_property
1 parent 0400d07 commit 7991fc2

File tree

14 files changed

+38
-43
lines changed

14 files changed

+38
-43
lines changed

Zend/zend_API.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,21 +4179,21 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const
41794179
}
41804180
/* }}} */
41814181

4182-
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
4182+
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */
41834183
{
41844184
zval *value;
41854185
zend_class_entry *old_scope = EG(fake_scope);
41864186

41874187
EG(fake_scope) = scope;
41884188

4189-
value = Z_OBJ_HT_P(object)->read_property(Z_OBJ_P(object), name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
4189+
value = object->handlers->read_property(object, name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
41904190

41914191
EG(fake_scope) = old_scope;
41924192
return value;
41934193
}
41944194
/* }}} */
41954195

4196-
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv) /* {{{ */
4196+
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) /* {{{ */
41974197
{
41984198
zval *value;
41994199
zend_string *str;

Zend/zend_API.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c
400400
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
401401
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);
402402

403-
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv);
404-
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
403+
ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv);
404+
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);
405405

406406
ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, zend_bool silent);
407407
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);

Zend/zend_exceptions.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
9999
ZVAL_OBJ(&zv, exception);
100100
ex = &zv;
101101
do {
102-
ancestor = zend_read_property_ex(i_get_exception_base(&pv), &pv, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
102+
ancestor = zend_read_property_ex(i_get_exception_base(&pv), Z_OBJ(pv), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
103103
while (Z_TYPE_P(ancestor) == IS_OBJECT) {
104104
if (Z_OBJ_P(ancestor) == Z_OBJ_P(ex)) {
105105
OBJ_RELEASE(add_previous);
106106
return;
107107
}
108-
ancestor = zend_read_property_ex(i_get_exception_base(ancestor), ancestor, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
108+
ancestor = zend_read_property_ex(i_get_exception_base(ancestor), Z_OBJ_P(ancestor), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
109109
}
110110
base_ce = i_get_exception_base(ex);
111-
previous = zend_read_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
111+
previous = zend_read_property_ex(base_ce, Z_OBJ_P(ex), ZSTR_KNOWN(ZEND_STR_PREVIOUS), 1, &rv);
112112
if (Z_TYPE_P(previous) == IS_NULL) {
113113
zend_update_property_ex(base_ce, ex, ZSTR_KNOWN(ZEND_STR_PREVIOUS), &pv);
114114
GC_DELREF(add_previous);
@@ -309,7 +309,7 @@ ZEND_METHOD(Exception, __construct)
309309

310310
/* {{{ Exception unserialize checks */
311311
#define CHECK_EXC_TYPE(id, type) \
312-
pvalue = zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &value); \
312+
pvalue = zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &value); \
313313
if (Z_TYPE_P(pvalue) != IS_NULL && Z_TYPE_P(pvalue) != type) { \
314314
zend_unset_property(i_get_exception_base(object), object, ZSTR_VAL(ZSTR_KNOWN(id)), ZSTR_LEN(ZSTR_KNOWN(id))); \
315315
}
@@ -375,9 +375,9 @@ ZEND_METHOD(ErrorException, __construct)
375375
/* }}} */
376376

377377
#define GET_PROPERTY(object, id) \
378-
zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 0, &rv)
378+
zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv)
379379
#define GET_PROPERTY_SILENT(object, id) \
380-
zend_read_property_ex(i_get_exception_base(object), (object), ZSTR_KNOWN(id), 1, &rv)
380+
zend_read_property_ex(i_get_exception_base(object), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv)
381381

382382
/* {{{ Get the file in which the exception occurred */
383383
ZEND_METHOD(Exception, getFile)
@@ -603,7 +603,7 @@ ZEND_METHOD(Exception, getTraceAsString)
603603
object = ZEND_THIS;
604604
base_ce = i_get_exception_base(object);
605605

606-
trace = zend_read_property_ex(base_ce, object, ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
606+
trace = zend_read_property_ex(base_ce, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv);
607607
if (EG(exception)) {
608608
RETURN_THROWS();
609609
}

ext/com_dotnet/com_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
278278
* and expose it as a COM exception */
279279

280280
if (wFlags & DISPATCH_PROPERTYGET) {
281-
retval = zend_read_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
281+
retval = zend_read_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name)+1, 1, &rv);
282282
} else if (wFlags & DISPATCH_PROPERTYPUT) {
283283
zend_update_property(Z_OBJCE(disp->object), &disp->object, Z_STRVAL_P(name), Z_STRLEN_P(name), &params[0]);
284284
} else if (wFlags & DISPATCH_METHOD) {

ext/curl/curl_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION
7171
zval *res, rv;
7272

7373
ZEND_PARSE_PARAMETERS_NONE();
74-
res = zend_read_property(curl_CURLFile_class, ZEND_THIS, name, name_len, 1, &rv);
74+
res = zend_read_property(curl_CURLFile_class, Z_OBJ_P(ZEND_THIS), name, name_len, 1, &rv);
7575
ZVAL_COPY_DEREF(return_value, res);
7676
}
7777

ext/curl/interface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
20472047
curl_seek_callback seekfunc = seek_cb;
20482048
#endif
20492049

2050-
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
2050+
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "name", sizeof("name")-1, 0, &rv);
20512051
if (Z_TYPE_P(prop) != IS_STRING) {
20522052
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
20532053
} else {
@@ -2057,11 +2057,11 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
20572057
return 1;
20582058
}
20592059

2060-
prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0, &rv);
2060+
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
20612061
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
20622062
type = Z_STRVAL_P(prop);
20632063
}
2064-
prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
2064+
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "postname", sizeof("postname")-1, 0, &rv);
20652065
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
20662066
filename = Z_STRVAL_P(prop);
20672067
}

ext/dom/php_dom.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,8 @@ static int dom_nodelist_has_dimension(zend_object *object, zval *member, int che
15391539
if (offset < 0) {
15401540
return 0;
15411541
} else {
1542-
zval obj;
1543-
zval *length;
1544-
1545-
ZVAL_OBJ(&obj, object);
1546-
length = zend_read_property(object->ce, &obj, "length", sizeof("length") - 1, 0, &rv);
1542+
zval *length = zend_read_property(
1543+
object->ce, object, "length", sizeof("length") - 1, 0, &rv);
15471544
return length && offset < Z_LVAL_P(length);
15481545
}
15491546
} /* }}} end dom_nodelist_has_dimension */

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5316,7 +5316,7 @@ ZEND_METHOD(ReflectionProperty, getValue)
53165316
RETURN_THROWS();
53175317
}
53185318

5319-
member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
5319+
member_p = zend_read_property_ex(intern->ce, Z_OBJ_P(object), ref->unmangled_name, 0, &rv);
53205320
if (member_p != &rv) {
53215321
ZVAL_COPY_DEREF(return_value, member_p);
53225322
} else {

ext/soap/php_encoding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ static void set_zval_property(zval* object, char* name, zval* val)
11701170
static zval* get_zval_property(zval* object, char* name, zval *rv)
11711171
{
11721172
if (Z_TYPE_P(object) == IS_OBJECT) {
1173-
zval *data = zend_read_property(Z_OBJCE_P(object), object, name, strlen(name), 1, rv);
1173+
zval *data = zend_read_property(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
11741174
if (data == &EG(uninitialized_zval)) {
11751175
return NULL;
11761176
}

ext/soap/soap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,10 @@ PHP_METHOD(SoapFault, __toString)
643643
}
644644

645645
this_ptr = ZEND_THIS;
646-
faultcode = zend_read_property(soap_fault_class_entry, this_ptr, "faultcode", sizeof("faultcode")-1, 1, &rv1);
647-
faultstring = zend_read_property(soap_fault_class_entry, this_ptr, "faultstring", sizeof("faultstring")-1, 1, &rv2);
648-
file = zend_read_property(soap_fault_class_entry, this_ptr, "file", sizeof("file")-1, 1, &rv3);
649-
line = zend_read_property(soap_fault_class_entry, this_ptr, "line", sizeof("line")-1, 1, &rv4);
646+
faultcode = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultcode", sizeof("faultcode")-1, 1, &rv1);
647+
faultstring = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "faultstring", sizeof("faultstring")-1, 1, &rv2);
648+
file = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "file", sizeof("file")-1, 1, &rv3);
649+
line = zend_read_property(soap_fault_class_entry, Z_OBJ_P(this_ptr), "line", sizeof("line")-1, 1, &rv4);
650650

651651
zend_call_method_with_0_params(
652652
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
11761176
} else if (instanceof_function(Z_OBJCE(exception_object), zend_ce_error)) {
11771177
if (service->send_errors) {
11781178
zval rv;
1179-
zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
1179+
zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
11801180
add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
11811181
zend_string_release_ex(msg, 0);
11821182
} else {
@@ -2241,7 +2241,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
22412241
zval exception_object;
22422242

22432243
ZVAL_OBJ(&exception_object, EG(exception));
2244-
msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
2244+
msg = zval_get_string(zend_read_property(zend_ce_error, Z_OBJ(exception_object), "message", sizeof("message")-1, 0, &rv));
22452245
/* change class */
22462246
EG(exception)->ce = soap_fault_class_entry;
22472247
set_soap_fault(&exception_object, NULL, "Client", ZSTR_VAL(msg), NULL, NULL, NULL);

0 commit comments

Comments
 (0)