[php-src] Issue #22547: ext/ldap: ldap_explode_dn() returned array no longer has count key in first position

[email protected] (Girgias) Thu, 2 Jul 2026 10:29:43 +0000
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/22547
Author: Girgias

Hello, commit https://github.com/php/php-src/commit/30bc98ce0a726221b6f6242e82ae2a43548612b1 changed the behavior of ldap_explode_dn, with the count key not being the first key anymore but the last one.
This breaking Nextcloud that was relying on this order (see https://github.com/nextcloud/server/issues/61446 )
This is also not matching the documentation at https://www.php.net/manual/en/function.ldap-explode-dn.php#refsect1-function.ldap-explode-dn-returnvalues

Was there a reason to change the key order? I see the tests were changed to test the new order so it does not look like an oversight. It was not documented in https://www.php.net/manual/en/migration85.incompatible.php#migration85.incompatible.ldap either.

We can (and probably will) change the code in Nextcloud to not rely on the order but I was quite surprised by this subtle and unannounced break.

_Originally posted by @come-nc in https://github.com/php/php-src/issues/16092#issuecomment-4833339294_