Skip to content

Use zend_array_is_list() in soap instead of own is_map() #18684

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

Merged
merged 1 commit into from
May 28, 2025
Merged
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
30 changes: 5 additions & 25 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
static zval *guess_zval_convert(zval *ret, encodeTypePtr type, xmlNodePtr data);
static xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style, xmlNodePtr parent);

static int is_map(zval *array);
static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *out_type);

static xmlNodePtr check_and_resolve_href(xmlNodePtr data);
Expand Down Expand Up @@ -1664,7 +1663,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
enc = model->u.element->encode;
if ((model->max_occurs == -1 || model->max_occurs > 1) &&
Z_TYPE_P(data) == IS_ARRAY &&
!is_map(data)) {
zend_array_is_list(Z_ARRVAL_P(data))) {
HashTable *ht = Z_ARRVAL_P(data);
zval *val;

Expand Down Expand Up @@ -1743,7 +1742,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
enc = get_conversion(XSD_ANYXML);
if ((model->max_occurs == -1 || model->max_occurs > 1) &&
Z_TYPE_P(data) == IS_ARRAY &&
!is_map(data)) {
zend_array_is_list(Z_ARRVAL_P(data))) {
HashTable *ht = Z_ARRVAL_P(data);
zval *val;

Expand Down Expand Up @@ -1918,7 +1917,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
sdlTypePtr array_el;

if (Z_TYPE_P(data) == IS_ARRAY &&
!is_map(data) &&
zend_array_is_list(Z_ARRVAL_P(data)) &&
sdlType->attributes == NULL &&
sdlType->model != NULL &&
(array_el = model_array_element(sdlType->model)) != NULL) {
Expand Down Expand Up @@ -2028,7 +2027,7 @@ static xmlNodePtr guess_array_map(encodeTypePtr type, zval *data, int style, xml
encodePtr enc = NULL;

if (data && Z_TYPE_P(data) == IS_ARRAY) {
if (is_map(data)) {
if (!zend_array_is_list(Z_ARRVAL_P(data))) {
enc = get_conversion(APACHE_MAP);
} else {
enc = get_conversion(SOAP_ENC_ARRAY);
Expand Down Expand Up @@ -3551,25 +3550,6 @@ encodePtr get_conversion(int encode)
}
}

static int is_map(zval *array)
{
zend_ulong index;
zend_string *key;
zend_ulong i = 0;

if (HT_IS_PACKED(Z_ARRVAL_P(array)) && HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(array))) {
return FALSE;
}

ZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(array), index, key) {
if (key || index != i) {
return TRUE;
}
i++;
} ZEND_HASH_FOREACH_END();
return FALSE;
}

static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
{
HashTable *ht;
Expand Down Expand Up @@ -3611,7 +3591,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
cur_ns = NULL;
}

} else if (Z_TYPE_P(tmp) == IS_ARRAY && is_map(tmp)) {
} else if (Z_TYPE_P(tmp) == IS_ARRAY && !zend_array_is_list(Z_ARRVAL_P(tmp))) {
cur_type = APACHE_MAP;
cur_stype = NULL;
cur_ns = NULL;
Expand Down