aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/User_Proxy.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib/User_Proxy.php')
-rw-r--r--apps/user_ldap/lib/User_Proxy.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 7786b8f0497..5079830b83c 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -13,12 +13,12 @@ use OCA\User_LDAP\User\User;
use OCP\IUserBackend;
use OCP\Notification\IManager as INotificationManager;
use OCP\User\Backend\ICountMappedUsersBackend;
-use OCP\User\Backend\ICountUsersBackend;
+use OCP\User\Backend\ILimitAwareCountUsersBackend;
use OCP\User\Backend\IProvideEnabledStateBackend;
use OCP\UserInterface;
use Psr\Log\LoggerInterface;
-class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP, ICountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend {
+class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP, ILimitAwareCountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend {
/** @var User_LDAP[] */
private array $backends = [];
private ?User_LDAP $refBackend = null;
@@ -350,17 +350,21 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
/**
* Count the number of users
- *
- * @return int|false
*/
- public function countUsers() {
+ public function countUsers(int $limit = 0): int|false {
$this->setup();
$users = false;
foreach ($this->backends as $backend) {
- $backendUsers = $backend->countUsers();
+ $backendUsers = $backend->countUsers($limit);
if ($backendUsers !== false) {
$users = (int)$users + $backendUsers;
+ if ($limit > 0) {
+ if ($users >= $limit) {
+ break;
+ }
+ $limit -= $users;
+ }
}
}
return $users;