From: Arthur Schiwon Date: Mon, 23 Mar 2015 15:51:40 +0000 (+0100) Subject: offset needs to be considered in computed limit X-Git-Tag: v7.0.6RC1~20^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bf7e2c756f8095b7946e5e82c0909b891d475389;p=nextcloud-server.git offset needs to be considered in computed limit --- diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index e8d268d3df2..cba19f3791c 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -630,7 +630,7 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { } $maxGroups = 100000; // limit max results (just for safety reasons) if ($limit > -1) { - $overallLimit = min($limit, $maxGroups); + $overallLimit = min($limit + $offset, $maxGroups); } else { $overallLimit = $maxGroups; } diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index d1262e4f5b8..8066bce02e3 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -294,4 +294,18 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase { $groupBackend->inGroup($uid, $gid); } + public function testGetGroupsWithOffset() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->expects($this->once()) + ->method('ownCloudGroupNames') + ->will($this->returnValue(array('group1', 'group2'))); + + $groupBackend = new GroupLDAP($access); + $groups = $groupBackend->getGroups('', 2, 2); + + $this->assertSame(2, count($groups)); + } + }