Parcourir la source

[ZF-11946] fixed iteration behavior on empty collections

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24612 44c647ce-9c0f-0410-b52a-842ac1e357ba
sgehrig il y a 14 ans
Parent
commit
3bf64f8be1
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 1
      library/Zend/Ldap/Collection/Iterator/Default.php

+ 3 - 1
library/Zend/Ldap/Collection/Iterator/Default.php

@@ -260,7 +260,7 @@ class Zend_Ldap_Collection_Iterator_Default implements Iterator, Countable
      */
     public function next()
     {
-        if (is_resource($this->_current)) {
+        if (is_resource($this->_current) && $this->_itemCount > 0) {
             $this->_current = @ldap_next_entry($this->_ldap->getResource(), $this->_current);
             /** @see Zend_Ldap_Exception */
             require_once 'Zend/Ldap/Exception.php';
@@ -273,6 +273,8 @@ class Zend_Ldap_Collection_Iterator_Default implements Iterator, Countable
                      throw new Zend_Ldap_Exception($this->_ldap, 'getting next entry (' . $msg . ')');
                 }
             }
+        } else {
+            $this->_current = false;
         }
     }