-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
ldap_search() fails when $attributes array has holes #17280
Comments
Hm right, the general handling of this function was improved on the master branch, but it will still be an issue because Lines 1484 to 1487 in 55afe8b
I believe this can be improved. |
Right, I think this can be relaxed and backported. |
Awesome, thanks ! |
We relax the constraint that the array must be a list. What really matters is that it only has numeric keys. As shown in the example code, it's really easy to accidentally create a non-list array, so it makes sense to relax the constraint. There are 3 cases left where the array is checked to be a list, in php_ldap_do_search, but I believe this makes sense to keep because the indices of those arrays have a meaning because they should match between different arrays. In that case it will prevent programmer errors.
I've filed a PR against master, and once that's merged I'll try to backport it. |
Merged into master, I'll be making a separate PR for the backport. |
…has holes Backport of phpGH-17284 to fix phpGH-17280 on lower branches.
…has holes Backport of phpGH-17284 to fix phpGH-17280 on lower branches.
* PHP-8.3: Backport fix GH-17280: ldap_search() fails when $attributes array has holes
* PHP-8.4: Backport fix GH-17280: ldap_search() fails when $attributes array has holes
Description
The following code:
Resulted in this output:
But I expected this output instead:
If $attr has no holes in the keys (i.e. remove array_unique() or call array_values()) then it works fine.
Maybe this is normal, but in that case I believe the documentation should clarify that, as it currently does not say anything about $attributes parameter needing to be a list with keys in a strict sequence.
PHP Version
8.2.27, 8.4.2
Operating System
MacOS 14.6.1
The text was updated successfully, but these errors were encountered: