diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-03-20 11:38:05 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-04-09 11:31:56 +0200 |
commit | 2e5adadad7b779f0794a6ecddb2b0f51b9214b4a (patch) | |
tree | b75753edf276ee8be174aec3aba8da36e790ec23 /apps | |
parent | bdc418d1f99738d45b2a0e4fab07c974d5b58681 (diff) | |
download | nextcloud-server-2e5adadad7b779f0794a6ecddb2b0f51b9214b4a.tar.gz nextcloud-server-2e5adadad7b779f0794a6ecddb2b0f51b9214b4a.zip |
Put inner loop into own method, let's see whether it makes scrutinizer happier
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/lib/access.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index d135ee5b735..ce97aaff145 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -794,15 +794,8 @@ class Access extends LDAPUtility { } list($sr, $pagedSearchOK) = $search; - foreach($sr as $key => $res) { - $count = $this->ldap->countEntries($cr, $res); - if($count !== false) { - $counter += $count; - } - if($count === $limit) { - $continue = true; - } - } + $count = $this->countEntriesInSearchResults($sr, $limit, $continue); + $counter += $count; $this->processPagedSearchStatus($sr, $filter, $base, $count, $limit, $offset, $pagedSearchOK, $skipHandling); @@ -812,6 +805,22 @@ class Access extends LDAPUtility { return $counter; } + private function countEntriesInSearchResults($searchResults, $limit, + &$hasHitLimit) { + $cr = $this->connection->getConnectionResource(); + $count = 0; + + foreach($searchResults as $res) { + $count = intval($this->ldap->countEntries($cr, $res)); + $counter += $count; + if($count === $limit) { + $hasHitLimit = true; + } + } + + return $counter; + } + /** * @brief executes an LDAP search * @param $filter the LDAP filter for the search |