Skip to content

Use zend_is_iterable #3146

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 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
return xmlParam;
}

if (Z_TYPE_P(data) == IS_OBJECT && instanceof_function(Z_OBJCE_P(data), zend_ce_traversable)) {
if (Z_TYPE_P(data) == IS_OBJECT && zend_is_iterable(data)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be replaced by just if (zend_is_iterable(data)) and moving array check (L2290:2455) to top of this part?

Copy link
Contributor

@tpunt tpunt Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not going to work, since code in this branch requires only an object (zend_is_iterable will return true for arrays, too).

Edit: changing zend_is_iterable to not accept all iterables is going to be a bit of a misnomer, also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing this PR as performance and check were affected :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpunt true, but it would fail even if it was an array as the first part of the conditional can never be true at that point, but I do agree we should evaluate each case before changing it, alternatively we can have some macros to cover common usages like the one in question here

zend_object_iterator *iter;
zend_class_entry *ce = Z_OBJCE_P(data);
zval *val;
Expand Down