Issues

ZF-8262: Zend_Ldap_Collection fails to check constraints, fails to return first result with current without seeking

Description

Zend_Ldap_Collection has a protected var _currentNumber that defaults to -1. Calling current() on a fresh Zend_Ldap_Collection returned by a search will result in Zend_Ldap_Collection searching for index -1 in an array that should be indexed with positive numbers. This then falls through to Zend_Ldap_Collection_Default where a similar error is made, all in all resulting in the inability to call current() without seeking first. There is a function getFirst(), however I would expect current() to return either NULL if no result exists (as in Zend_Db_Table_Rowset_Abstract) or the first result if I do not seek.

Comments

Fixed in trunk (r18921)

Removed dependency on calling {{Zend_Ldap_Collection::rewind()}} before using {{Zend_Ldap_Collection::current()}} and/or {{Zend_Ldap_Collection::key()}}. {{Zend_Ldap_Collection::rewind()}} will be called internally if iteration has not been started yet.

Added {{Zend_Ldap_Collection::getInnerIterator()}} to return the underlying {{Zend_Ldap_Collection_Iterator_Default}}.

Added {{Zend_Ldap_Collection::dn()}} to accompany {{Zend_Ldap_Collection::key()}}. The latter returns the numerical index of the current result item within the result set, the former returns its DN.