From fdeb02876fe3906d478eb165f7b09f5d5b91fdc2 Mon Sep 17 00:00:00 2001 From: Domisys Date: Thu, 30 Aug 2012 12:44:33 +0300 Subject: [PATCH] Update library/Zend/Ldap/Collection/DefaultIterator.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't use $ldap->getResource() in ldap_* functions to avoid « ErrorHandler already started » error. --- src/Collection/DefaultIterator.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Collection/DefaultIterator.php b/src/Collection/DefaultIterator.php index 3d94aa6ad..7e2afbd48 100644 --- a/src/Collection/DefaultIterator.php +++ b/src/Collection/DefaultIterator.php @@ -75,8 +75,9 @@ public function __construct(Ldap\Ldap $ldap, $resultId) $this->ldap = $ldap; $this->resultId = $resultId; + $resource = $ldap->getResource(); ErrorHandler::start(); - $this->itemCount = ldap_count_entries($ldap->getResource(), $resultId); + $this->itemCount = ldap_count_entries($resource, $resultId); ErrorHandler::stop(); if ($this->itemCount === false) { throw new Exception\LdapException($this->ldap, 'counting entries'); @@ -199,16 +200,17 @@ public function current() $entry = array('dn' => $this->key()); $ber_identifier = null; + $resource = $this->ldap->getResource(); ErrorHandler::start(); $name = ldap_first_attribute( - $this->ldap->getResource(), $this->current, + $resource, $this->current, $ber_identifier ); ErrorHandler::stop(); while ($name) { ErrorHandler::start(); - $data = ldap_get_values_len($this->ldap->getResource(), $this->current, $name); + $data = ldap_get_values_len($resource, $this->current, $name); ErrorHandler::stop(); if (!$data) { @@ -237,7 +239,7 @@ public function current() ErrorHandler::start(); $name = ldap_next_attribute( - $this->ldap->getResource(), $this->current, + $resource, $this->current, $ber_identifier ); ErrorHandler::stop(); @@ -259,8 +261,9 @@ public function key() $this->rewind(); } if (is_resource($this->current)) { + $resource = $this->ldap->getResource(); ErrorHandler::start(); - $currentDn = ldap_get_dn($this->ldap->getResource(), $this->current); + $currentDn = ldap_get_dn($resource, $this->current); ErrorHandler::stop(); if ($currentDn === false) { @@ -285,8 +288,9 @@ public function next() $code = 0; if (is_resource($this->current) && $this->itemCount > 0) { + $resource = $this->ldap->getResource(); ErrorHandler::start(); - $this->current = ldap_next_entry($this->ldap->getResource(), $this->current); + $this->current = ldap_next_entry($resource, $this->current); ErrorHandler::stop(); if ($this->current === false) { $msg = $this->ldap->getLastError($code); @@ -312,8 +316,9 @@ public function next() public function rewind() { if (is_resource($this->resultId)) { + $resource = $this->ldap->getResource(); ErrorHandler::start(); - $this->current = ldap_first_entry($this->ldap->getResource(), $this->resultId); + $this->current = ldap_first_entry($resource, $this->resultId); ErrorHandler::stop(); if ($this->current === false && $this->ldap->getLastErrorCode() > Exception\LdapException::LDAP_SUCCESS