ZF-11946: Zend_Ldap_Collection::toArray throws exception instead of returning array


When I try to perform Zend_Ldap::search(...)->toArray(), an exception is thrown:

Message: 0x54 (Decoding error): getting next entry (0x54 (Decoding error))

The actual problem is in Zend_Ldap_Collection_Iterator_Default::next(), which internally calls PHP's ldap_next_entry(). Upon reaching the end of the found entries, which is indicated by returning FALSE by ldap_next_entry(), Zend_Ldap_Collection_Iterator_Default::next() throws the exception instead of returning.


Could not really reproduce this issue but added a second safe-guard against an exception on an empty search result