Skip to content

ext/ldap: Various refactorings to php_ldap_do_search() #16104

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 6 commits into from
Sep 30, 2024

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 28, 2024

There is much more to be done here, such as checking the PHP int inputs fit into a C int (and possibly are >= 0, but that would require changing the default value from -1 to 0), turning the $attributes_only parameter into a bool, and possibly just split the batch processing functionality into new functions.

However, this should already address some issues and improve code readability.

Depends partially on: #16102

@Girgias Girgias requested a review from nielsdos September 28, 2024 16:50
@Girgias Girgias force-pushed the ldap-list-search-refacto branch 2 times, most recently from d69827a to a99be0a Compare September 28, 2024 18:49

zend_ulong attribute_index = 0;
zval *attribute_zv = NULL;
ZEND_HASH_FOREACH_NUM_KEY_VAL(attributes, attribute_index, attribute_zv) {
Copy link
Member

@nielsdos nielsdos Sep 28, 2024

Choose a reason for hiding this comment

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

I'm pretty certain that references are not handled here, which results in a strange must be a list of strings, string given (probably similarly for other foreaches).

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is I tried adding a test as I was thinking the same, and yet it seems to be handled.

I don't really get it, like the only thing which would make some sense is if separating the array would also deref the entries, but that seems improbable.

Copy link
Member

Choose a reason for hiding this comment

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

Can you share your test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahhh wait this is about the attributes and not the filter/base_dn arrays.

I did miss this will check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I added a test, and indeed it does work (which is very confusing to me)

Copy link
Member

Choose a reason for hiding this comment

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

@Girgias That's not how you create a reference in an array, dump that into debug_zval_dump and you'll see these aren't references.

Copy link
Member Author

Choose a reason for hiding this comment

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

sigh

@Girgias Girgias force-pushed the ldap-list-search-refacto branch from a99be0a to 1df3ca8 Compare September 29, 2024 14:36
@Girgias Girgias force-pushed the ldap-list-search-refacto branch from 1df3ca8 to e205514 Compare September 29, 2024 14:57
@Girgias Girgias merged commit d87711b into php:master Sep 30, 2024
9 of 10 checks passed
@Girgias Girgias deleted the ldap-list-search-refacto branch September 30, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants