Skip to content

Declare ext/soap properties #6759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -4690,6 +4690,16 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object,
}
/* }}} */

ZEND_API zval *zend_read_property_deref(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv)
{
zval *value;

value = zend_read_property(scope, object, name, name_length, silent, rv);
ZVAL_DEREF(value);

return value;
}

ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent) /* {{{ */
{
zval *property;
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope

ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv);
ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv);
ZEND_API zval *zend_read_property_deref(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv);

ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent);
Expand Down
49 changes: 24 additions & 25 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,17 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
Z_OBJCE_P(data) == soap_var_class_entry) {
zval *ztype, *zdata, *zns, *zstype, *zname, *znamens;
encodePtr enc = NULL;
HashTable *ht = Z_OBJPROP_P(data);
zval rv;

if ((ztype = zend_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL ||
Z_TYPE_P(ztype) != IS_LONG) {
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_type", sizeof("enc_type")-1, 1, &rv);
if (Z_TYPE_P(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}

if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL &&
Z_TYPE_P(zstype) == IS_STRING) {
if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL &&
Z_TYPE_P(zns) == IS_STRING) {
zstype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
if (Z_TYPE_P(zstype) == IS_STRING) {
zns = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
if (Z_TYPE_P(zns) == IS_STRING) {
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_P(zns), Z_STRVAL_P(zstype));
} else {
zns = NULL;
Expand All @@ -420,27 +420,27 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
enc = encode;
}

zdata = zend_hash_str_find_deref(ht, "enc_value", sizeof("enc_value")-1);
zdata = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_value", sizeof("enc_value")-1, 1, &rv);
node = master_to_xml(enc, zdata, style, parent);

if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL &&
Z_TYPE_P(zstype) == IS_STRING) {
if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL &&
Z_TYPE_P(zns) == IS_STRING) {
zstype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
if (Z_TYPE_P(zstype) == IS_STRING) {
zns = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
if (Z_TYPE_P(zns) == IS_STRING) {
set_ns_and_type_ex(node, Z_STRVAL_P(zns), Z_STRVAL_P(zstype));
} else {
set_ns_and_type_ex(node, NULL, Z_STRVAL_P(zstype));
}
}
}

if ((zname = zend_hash_str_find_deref(ht, "enc_name", sizeof("enc_name")-1)) != NULL &&
Z_TYPE_P(zname) == IS_STRING) {
zname = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_name", sizeof("enc_name")-1, 1, &rv);
if (Z_TYPE_P(zname) == IS_STRING) {
xmlNodeSetName(node, BAD_CAST(Z_STRVAL_P(zname)));
}
if ((znamens = zend_hash_str_find_deref(ht, "enc_namens", sizeof("enc_namens")-1)) != NULL &&
Z_TYPE_P(znamens) == IS_STRING) {
znamens = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(data), "enc_namens", sizeof("enc_namens")-1, 1, &rv);
if (Z_TYPE_P(znamens) == IS_STRING) {
xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_P(znamens));
xmlSetNs(node, nsp);
}
Expand Down Expand Up @@ -1170,11 +1170,10 @@ 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), Z_OBJ_P(object), name, strlen(name), 1, rv);
zval *data = zend_read_property_deref(Z_OBJCE_P(object), Z_OBJ_P(object), name, strlen(name), 1, rv);
if (data == &EG(uninitialized_zval)) {
return NULL;
}
ZVAL_DEREF(data);
return data;
} else if (Z_TYPE_P(object) == IS_ARRAY) {
return zend_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name));
Expand Down Expand Up @@ -3477,7 +3476,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
{
HashTable *ht;
int i, cur_type, prev_type, different;
zval *tmp;
zval *tmp, rv;
char *prev_stype = NULL, *cur_stype = NULL, *prev_ns = NULL, *cur_ns = NULL;

if (!array || Z_TYPE_P(array) != IS_ARRAY) {
Expand All @@ -3496,21 +3495,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
Z_OBJCE_P(tmp) == soap_var_class_entry) {
zval *ztype;

if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL ||
Z_TYPE_P(ztype) != IS_LONG) {
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_type", sizeof("enc_type")-1, 1, &rv);
if (Z_TYPE_P(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_P(ztype);

if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL &&
Z_TYPE_P(ztype) == IS_STRING) {
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_stype", sizeof("enc_stype")-1, 1, &rv);
if (Z_TYPE_P(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_P(ztype);
} else {
cur_stype = NULL;
}

if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_ns", sizeof("enc_ns")-1)) != NULL &&
Z_TYPE_P(ztype) == IS_STRING) {
ztype = zend_read_property_deref(soap_var_class_entry, Z_OBJ_P(tmp), "enc_ns", sizeof("enc_ns")-1, 1, &rv);
if (Z_TYPE_P(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_P(ztype);
} else {
cur_ns = NULL;
Expand Down
Loading