From fdf73d26f011da7acee6fddd3674f848a811d345 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 3 Sep 2024 15:13:49 +0200 Subject: [PATCH] perf: don't loop the users without any provisioning configurations Signed-off-by: Daniel Kesselberg --- lib/Service/Provisioning/Manager.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Service/Provisioning/Manager.php b/lib/Service/Provisioning/Manager.php index bc69f64e8f..119633966f 100644 --- a/lib/Service/Provisioning/Manager.php +++ b/lib/Service/Provisioning/Manager.php @@ -100,14 +100,20 @@ public function getConfigs(): array { } public function provision(): int { - $cnt = 0; + $counter = 0; + $configs = $this->getConfigs(); - $this->userManager->callForAllUsers(function (IUser $user) use ($configs, &$cnt) { - if ($this->provisionSingleUser($configs, $user) === true) { - $cnt++; + if (count($configs) === 0) { + return $counter; + } + + $this->userManager->callForAllUsers(function (IUser $user) use ($configs, &$counter) { + if ($this->provisionSingleUser($configs, $user)) { + $counter++; } }); - return $cnt; + + return $counter; } /**