From b71ca7b78c06a6930256e34752ed86dd5f1519c9 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 15:52:56 +0530 Subject: [PATCH 01/10] (fix) use LazyConfig to avoid loading into cache --- .../RecoveryWarningNotificationCommand.php | 40 ++++++++++++------ lib/Config/LazyConfig.php | 41 +++++++++++++++++++ 2 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 lib/Config/LazyConfig.php diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index ccc22e5..8fd98ee 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -8,7 +8,8 @@ use OCA\EmailRecovery\AppInfo\Application; use OCA\EmailRecovery\Service\NotificationService; use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Utility\ITimeFactory; -use OCP\IConfig; +use OCA\EmailRecovery\Config\LazyConfig; +use OCP\IUser; use OCP\IGroupManager; use OCP\IURLGenerator; use OCP\IUserManager; @@ -21,7 +22,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class RecoveryWarningNotificationCommand extends Command { - private IConfig $config; private IUserManager $userManager; private IGroupManager $groupManager; private RecoveryEmailService $recoveryEmailService; @@ -48,7 +48,6 @@ class RecoveryWarningNotificationCommand extends Command { private array $deleteUids = []; public function __construct( - IConfig $config, IUserManager $userManager, IGroupManager $groupManager, RecoveryEmailService $recoveryEmailService, @@ -56,10 +55,10 @@ class RecoveryWarningNotificationCommand extends Command { IManager $notificationManager, IURLGenerator $urlGenerator, ITimeFactory $timeFactory, - NotificationService $notificationService + NotificationService $notificationService, + private LazyConfig $config ) { parent::__construct(); - $this->config = $config; $this->userManager = $userManager; $this->groupManager = $groupManager; $this->recoveryEmailService = $recoveryEmailService; @@ -235,9 +234,9 @@ class RecoveryWarningNotificationCommand extends Command { } $uid = $user->getUID(); - $emailAddress = $user->getEMailAddress(); + $emailAddress = $this->getEmailAddress($uid); - $verifiedRecoveryEmail = $this->recoveryEmailService->getRecoveryEmail($username); + $verifiedRecoveryEmail = $this->getRecoveryEmail($username); if (!empty($verifiedRecoveryEmail)) { $skippedCount++; @@ -255,12 +254,12 @@ class RecoveryWarningNotificationCommand extends Command { } // Check if disable date is already set, if not set it - $existingDisableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); + $existingDisableDate = $this->getUnverifiedUserDisableAt($uid); if (empty($existingDisableDate)) { // Set the disable date using config variable $disableDate = date('Y-m-d', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60)); - $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); + $this->setUnverifiedUserDisableAt($uid, $disableDate); $existingDisableDate = $disableDate; } @@ -467,7 +466,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; - $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); + $disableDate = $this->getUnverifiedUserDisableAt($uid); $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } @@ -586,12 +585,29 @@ class RecoveryWarningNotificationCommand extends Command { } } + private function getRecoveryEmail(string $username) : string { + return $this->config->getUserValue($username, $this->appName, 'recovery-email', ''); + } + + private function getEmailAddress(string $uid): ?string { + $emailAddress = $this->config->getUserValue($uid, 'settings', 'email', null); + $emailAddress = $emailAddress ? mb_strtolower(trim($email)) : null; + return $emailAddress; + } + + private function getUnverifiedUserDisableAt(string $uid): string { + return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, ''); + } + private function setUnverifiedUserDisableAt(string $uid, string $disableDate): void { + $this->config->setUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, $disableDate); + } + private function isUserValid($user): bool { - if (!($user instanceof \OCP\IUser)) { + if (!($user instanceof IUser)) { return false; } - $emailAddress = $user->getEMailAddress(); + $emailAddress = $this->getEmailAddress($user->getUID()); return $emailAddress && $this->mailer->validateMailAddress($emailAddress); } diff --git a/lib/Config/LazyConfig.php b/lib/Config/LazyConfig.php new file mode 100644 index 0000000..51fb439 --- /dev/null +++ b/lib/Config/LazyConfig.php @@ -0,0 +1,41 @@ +hasKey($userId, $appName, $key, true)) { + return $default; + } + return $userPreferences->getValueMixed($userId, $appName, $key, $default ?? '', true); + } + + public function setUserValue($userId, $appName, $key, $value, $preCondition = null) { + if (!is_int($value) && !is_float($value) && !is_string($value)) { + throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value'); + } + + /** @var UserConfig $userPreferences */ + $userPreferences = \OCP\Server::get(IUserConfig::class); + if ($preCondition !== null) { + try { + if ($userPreferences->hasKey($userId, $appName, $key, true) && $userPreferences->getValueMixed($userId, $appName, $key, true) !== (string)$preCondition) { + throw new PreConditionNotMetException(); + } + } catch (TypeConflictException) { + } + } + + $userPreferences->setValueMixed($userId, $appName, $key, (string)$value); + } +} -- GitLab From e338e28e5f93700b3617b2392f8e28ed9a2fd469 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 16:36:56 +0530 Subject: [PATCH 02/10] (fix) clearCache of UserConfig before each request --- lib/Command/RecoveryWarningNotificationCommand.php | 7 +++++-- lib/Config/LazyConfig.php | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 8fd98ee..e7c74d8 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -8,7 +8,7 @@ use OCA\EmailRecovery\AppInfo\Application; use OCA\EmailRecovery\Service\NotificationService; use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Utility\ITimeFactory; -use OCA\EmailRecovery\Config\LazyConfig; +use OCP\IConfig; use OCP\IUser; use OCP\IGroupManager; use OCP\IURLGenerator; @@ -16,6 +16,7 @@ use OCP\IUserManager; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Notification\IManager; +use NCU\Config\IUserConfig; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -56,7 +57,7 @@ class RecoveryWarningNotificationCommand extends Command { IURLGenerator $urlGenerator, ITimeFactory $timeFactory, NotificationService $notificationService, - private LazyConfig $config + private IConfig $config ) { parent::__construct(); $this->userManager = $userManager; @@ -210,6 +211,8 @@ class RecoveryWarningNotificationCommand extends Command { $premiumSkippedCount = 0; foreach ($users as $username) { + $userPreferences = \OCP\Server::get(IUserConfig::class); + $userPreferences->clearCacheAll(); try { $user = $this->getUser($username); diff --git a/lib/Config/LazyConfig.php b/lib/Config/LazyConfig.php index 51fb439..d374dc1 100644 --- a/lib/Config/LazyConfig.php +++ b/lib/Config/LazyConfig.php @@ -5,19 +5,23 @@ namespace OCA\EmailRecovery\Config; use OC\AllConfig; use OCP\PreConditionNotMetException; use NCU\Config\Exceptions\TypeConflictException; +use NCU\Config\IUserConfig; class LazyConfig extends AllConfig { public function getUserValue($userId, $appName, $key, $default = '') { + $userPreferences = \OCP\Server::get(IUserConfig::class); + $userPreferences->clearCacheAll(); + if ($userId === null || $userId === '') { return $default; } /** @var UserConfig $userPreferences */ $userPreferences = \OCP\Server::get(IUserConfig::class); // because $default can be null ... - if (!$userPreferences->hasKey($userId, $appName, $key, true)) { + if (!$userPreferences->hasKey($userId, $appName, $key)) { return $default; } - return $userPreferences->getValueMixed($userId, $appName, $key, $default ?? '', true); + return $userPreferences->getValueMixed($userId, $appName, $key, $default ?? ''); } public function setUserValue($userId, $appName, $key, $value, $preCondition = null) { @@ -29,7 +33,7 @@ class LazyConfig extends AllConfig { $userPreferences = \OCP\Server::get(IUserConfig::class); if ($preCondition !== null) { try { - if ($userPreferences->hasKey($userId, $appName, $key, true) && $userPreferences->getValueMixed($userId, $appName, $key, true) !== (string)$preCondition) { + if ($userPreferences->hasKey($userId, $appName, $key) && $userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) { throw new PreConditionNotMetException(); } } catch (TypeConflictException) { -- GitLab From b749e4238ce72513af7c0f823fc677ffb2b46ba8 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 16:46:11 +0530 Subject: [PATCH 03/10] (fix) clearCache of UserConfig for every 10000 users --- .../RecoveryWarningNotificationCommand.php | 41 +++++++---------- lib/Config/LazyConfig.php | 45 ------------------- 2 files changed, 16 insertions(+), 70 deletions(-) delete mode 100644 lib/Config/LazyConfig.php diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index e7c74d8..f4bce8a 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -209,10 +209,18 @@ class RecoveryWarningNotificationCommand extends Command { $invalidCount = 0; $errorCount = 0; $premiumSkippedCount = 0; + $cacheClearCount = 0; foreach ($users as $username) { - $userPreferences = \OCP\Server::get(IUserConfig::class); - $userPreferences->clearCacheAll(); + + $cacheClearCount++; + + // Clear the user config cache for every 10000 users + if ($cacheClearCount >= 10000) { + $userPreferences = \OCP\Server::get(IUserConfig::class); + $userPreferences->clearCacheAll(); + $cacheClearCount = 0; + } try { $user = $this->getUser($username); @@ -237,9 +245,9 @@ class RecoveryWarningNotificationCommand extends Command { } $uid = $user->getUID(); - $emailAddress = $this->getEmailAddress($uid); + $emailAddress = $user->getEMailAddress(); - $verifiedRecoveryEmail = $this->getRecoveryEmail($username); + $verifiedRecoveryEmail = $this->recoveryEmailService->getRecoveryEmail($username); if (!empty($verifiedRecoveryEmail)) { $skippedCount++; @@ -257,12 +265,12 @@ class RecoveryWarningNotificationCommand extends Command { } // Check if disable date is already set, if not set it - $existingDisableDate = $this->getUnverifiedUserDisableAt($uid); + $existingDisableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); if (empty($existingDisableDate)) { // Set the disable date using config variable $disableDate = date('Y-m-d', $firstRunDate + ($this->disableUserAfterUnverifiedDays * 24 * 60 * 60)); - $this->setUnverifiedUserDisableAt($uid, $disableDate); + $this->recoveryEmailService->setUnverifiedUserDisableAt($uid, $disableDate); $existingDisableDate = $disableDate; } @@ -469,7 +477,7 @@ class RecoveryWarningNotificationCommand extends Command { $translations = $this->notificationService->getTranslatedSubjectAndMessage($this->messageId, $language); $message = $translations['message']; - $disableDate = $this->getUnverifiedUserDisableAt($uid); + $disableDate = $this->recoveryEmailService->getUnverifiedUserDisableAt($uid); $parsedMessage = $this->notificationService->getParsedString($message, $username, $disableDate); return $parsedMessage['message']; } @@ -588,29 +596,12 @@ class RecoveryWarningNotificationCommand extends Command { } } - private function getRecoveryEmail(string $username) : string { - return $this->config->getUserValue($username, $this->appName, 'recovery-email', ''); - } - - private function getEmailAddress(string $uid): ?string { - $emailAddress = $this->config->getUserValue($uid, 'settings', 'email', null); - $emailAddress = $emailAddress ? mb_strtolower(trim($email)) : null; - return $emailAddress; - } - - private function getUnverifiedUserDisableAt(string $uid): string { - return $this->config->getUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, ''); - } - private function setUnverifiedUserDisableAt(string $uid, string $disableDate): void { - $this->config->setUserValue($uid, $this->appName, self::UNVERIFIED_USER_DISABLE_AT, $disableDate); - } - private function isUserValid($user): bool { if (!($user instanceof IUser)) { return false; } - $emailAddress = $this->getEmailAddress($user->getUID()); + $emailAddress = $user->getEMailAddress(); return $emailAddress && $this->mailer->validateMailAddress($emailAddress); } diff --git a/lib/Config/LazyConfig.php b/lib/Config/LazyConfig.php deleted file mode 100644 index d374dc1..0000000 --- a/lib/Config/LazyConfig.php +++ /dev/null @@ -1,45 +0,0 @@ -clearCacheAll(); - - if ($userId === null || $userId === '') { - return $default; - } - /** @var UserConfig $userPreferences */ - $userPreferences = \OCP\Server::get(IUserConfig::class); - // because $default can be null ... - if (!$userPreferences->hasKey($userId, $appName, $key)) { - return $default; - } - return $userPreferences->getValueMixed($userId, $appName, $key, $default ?? ''); - } - - public function setUserValue($userId, $appName, $key, $value, $preCondition = null) { - if (!is_int($value) && !is_float($value) && !is_string($value)) { - throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value'); - } - - /** @var UserConfig $userPreferences */ - $userPreferences = \OCP\Server::get(IUserConfig::class); - if ($preCondition !== null) { - try { - if ($userPreferences->hasKey($userId, $appName, $key) && $userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) { - throw new PreConditionNotMetException(); - } - } catch (TypeConflictException) { - } - } - - $userPreferences->setValueMixed($userId, $appName, $key, (string)$value); - } -} -- GitLab From e39598dcfb40c5047092547cec4c50b0e4d194d6 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 16:54:38 +0530 Subject: [PATCH 04/10] (fix) clear cache of group manager too --- lib/Command/RecoveryWarningNotificationCommand.php | 7 +++---- lib/Group/CacheControlledManager.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 lib/Group/CacheControlledManager.php diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index f4bce8a..eec9d6f 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -10,7 +10,7 @@ use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IUser; -use OCP\IGroupManager; +use OCA\EmailRecovery\Group\CacheControlledManager; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Mail\IEMailTemplate; @@ -24,7 +24,6 @@ use Symfony\Component\Console\Output\OutputInterface; class RecoveryWarningNotificationCommand extends Command { private IUserManager $userManager; - private IGroupManager $groupManager; private RecoveryEmailService $recoveryEmailService; private IMailer $mailer; @@ -50,18 +49,17 @@ class RecoveryWarningNotificationCommand extends Command { public function __construct( IUserManager $userManager, - IGroupManager $groupManager, RecoveryEmailService $recoveryEmailService, IMailer $mailer, IManager $notificationManager, IURLGenerator $urlGenerator, ITimeFactory $timeFactory, NotificationService $notificationService, + private CacheControllerManager $groupManager, private IConfig $config ) { parent::__construct(); $this->userManager = $userManager; - $this->groupManager = $groupManager; $this->recoveryEmailService = $recoveryEmailService; $this->mailer = $mailer; $this->notificationManager = $notificationManager; @@ -219,6 +217,7 @@ class RecoveryWarningNotificationCommand extends Command { if ($cacheClearCount >= 10000) { $userPreferences = \OCP\Server::get(IUserConfig::class); $userPreferences->clearCacheAll(); + $this->groupManager->clearCacheAll(); $cacheClearCount = 0; } try { diff --git a/lib/Group/CacheControlledManager.php b/lib/Group/CacheControlledManager.php new file mode 100644 index 0000000..57debf0 --- /dev/null +++ b/lib/Group/CacheControlledManager.php @@ -0,0 +1,11 @@ +clearCacheAll(); + } +} -- GitLab From 4bc65b29baf40b5620a27e7779d5e7d9f8219398 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 16:55:35 +0530 Subject: [PATCH 05/10] (fix) typo fixed in group manager name --- lib/Command/RecoveryWarningNotificationCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index eec9d6f..76c9a8c 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -55,7 +55,7 @@ class RecoveryWarningNotificationCommand extends Command { IURLGenerator $urlGenerator, ITimeFactory $timeFactory, NotificationService $notificationService, - private CacheControllerManager $groupManager, + private CacheControlledManager $groupManager, private IConfig $config ) { parent::__construct(); -- GitLab From 0ead8a23204cda7430233e28be3b81c689373301 Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 19 Dec 2025 16:57:08 +0530 Subject: [PATCH 06/10] (chore) run php cs fixer --- lib/Command/RecoveryWarningNotificationCommand.php | 1 - lib/Group/CacheControlledManager.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 76c9a8c..285078f 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -210,7 +210,6 @@ class RecoveryWarningNotificationCommand extends Command { $cacheClearCount = 0; foreach ($users as $username) { - $cacheClearCount++; // Clear the user config cache for every 10000 users diff --git a/lib/Group/CacheControlledManager.php b/lib/Group/CacheControlledManager.php index 57debf0..cfbc9c1 100644 --- a/lib/Group/CacheControlledManager.php +++ b/lib/Group/CacheControlledManager.php @@ -1,8 +1,8 @@ Date: Mon, 22 Dec 2025 18:13:41 +0530 Subject: [PATCH 07/10] (chore) allow temporary staging deploys --- .gitlab-ci.yml | 17 +++++++++++++++++ .../RecoveryWarningNotificationCommand.php | 9 +++++++-- lib/Group/CacheControlledManager.php | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9215688..e8c7a96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,3 +29,20 @@ include: ref: main file: "nc-publish-app.yml" + +deploy:staging: + extends: .deploy:nextcloud-app + rules: + - if: $CI_COMMIT_BRANCH == "main" + when: manual + - if: $CI_COMMIT_BRANCH == "murena-main" + when: manual + - if: $CI_COMMIT_BRANCH == "production" + when: manual + - if: $CI_COMMIT_BRANCH == "dev/notification-memory-leaks" + when: manual + - if: $CI_COMMIT_TAG + when: manual + environment: + name: staging/01 + url: $ENV_URL diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 285078f..00fa708 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -10,6 +10,7 @@ use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IUser; +use OCP\Util; use OCA\EmailRecovery\Group\CacheControlledManager; use OCP\IURLGenerator; use OCP\IUserManager; @@ -56,7 +57,8 @@ class RecoveryWarningNotificationCommand extends Command { ITimeFactory $timeFactory, NotificationService $notificationService, private CacheControlledManager $groupManager, - private IConfig $config + private IConfig $config, + private Util $util ) { parent::__construct(); $this->userManager = $userManager; @@ -208,12 +210,15 @@ class RecoveryWarningNotificationCommand extends Command { $errorCount = 0; $premiumSkippedCount = 0; $cacheClearCount = 0; + $totalCount = 0; foreach ($users as $username) { $cacheClearCount++; - + $totalCount++; // Clear the user config cache for every 10000 users if ($cacheClearCount >= 10000) { + $currentMemoryUsage = memory_get_usage(); + $output->writeln("Current memory usage after $totalCount users: " . $this->util->humanFileSize($currentMemoryUsage)); $userPreferences = \OCP\Server::get(IUserConfig::class); $userPreferences->clearCacheAll(); $this->groupManager->clearCacheAll(); diff --git a/lib/Group/CacheControlledManager.php b/lib/Group/CacheControlledManager.php index cfbc9c1..130abc4 100644 --- a/lib/Group/CacheControlledManager.php +++ b/lib/Group/CacheControlledManager.php @@ -5,7 +5,7 @@ namespace OCA\EmailRecovery\Group; use OC\Group\Manager; class CacheControlledManager extends Manager { - public function emptyCaches() { - $this->clearCacheAll(); + public function clearCacheAll() { + $this->clearCaches(); } } -- GitLab From 72e42eee78e9551aaf52093f81eba197b16392ac Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 24 Dec 2025 16:04:00 +0530 Subject: [PATCH 08/10] (fix) remove CacheControlledGroupManager --- lib/Command/RecoveryWarningNotificationCommand.php | 9 +++++---- lib/Group/CacheControlledManager.php | 11 ----------- 2 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 lib/Group/CacheControlledManager.php diff --git a/lib/Command/RecoveryWarningNotificationCommand.php b/lib/Command/RecoveryWarningNotificationCommand.php index 00fa708..81981a0 100644 --- a/lib/Command/RecoveryWarningNotificationCommand.php +++ b/lib/Command/RecoveryWarningNotificationCommand.php @@ -11,7 +11,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IUser; use OCP\Util; -use OCA\EmailRecovery\Group\CacheControlledManager; +use OCP\IGroupManager; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Mail\IEMailTemplate; @@ -56,7 +56,7 @@ class RecoveryWarningNotificationCommand extends Command { IURLGenerator $urlGenerator, ITimeFactory $timeFactory, NotificationService $notificationService, - private CacheControlledManager $groupManager, + private IGroupManager $groupManager, private IConfig $config, private Util $util ) { @@ -216,12 +216,13 @@ class RecoveryWarningNotificationCommand extends Command { $cacheClearCount++; $totalCount++; // Clear the user config cache for every 10000 users - if ($cacheClearCount >= 10000) { + if ($cacheClearCount >= 1000) { $currentMemoryUsage = memory_get_usage(); $output->writeln("Current memory usage after $totalCount users: " . $this->util->humanFileSize($currentMemoryUsage)); $userPreferences = \OCP\Server::get(IUserConfig::class); $userPreferences->clearCacheAll(); - $this->groupManager->clearCacheAll(); + $currentMemoryUsage = memory_get_usage(); + $output->writeln("Current memory usage after clearing cache: " . $this->util->humanFileSize($currentMemoryUsage)); $cacheClearCount = 0; } try { diff --git a/lib/Group/CacheControlledManager.php b/lib/Group/CacheControlledManager.php deleted file mode 100644 index 130abc4..0000000 --- a/lib/Group/CacheControlledManager.php +++ /dev/null @@ -1,11 +0,0 @@ -clearCaches(); - } -} -- GitLab From 1ed25cf98bea888633a821b0b47650b7fc2dcf65 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 24 Dec 2025 16:36:52 +0530 Subject: [PATCH 09/10] (chore) remove temporary staging deploy changes --- .gitlab-ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e8c7a96..ebc28ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,21 +28,3 @@ include: - project: "e/infra/ecloud/nextcloud-apps/ci-templates" ref: main file: "nc-publish-app.yml" - - -deploy:staging: - extends: .deploy:nextcloud-app - rules: - - if: $CI_COMMIT_BRANCH == "main" - when: manual - - if: $CI_COMMIT_BRANCH == "murena-main" - when: manual - - if: $CI_COMMIT_BRANCH == "production" - when: manual - - if: $CI_COMMIT_BRANCH == "dev/notification-memory-leaks" - when: manual - - if: $CI_COMMIT_TAG - when: manual - environment: - name: staging/01 - url: $ENV_URL -- GitLab From e32f7ae7a5db7cdbb618d0811d682e6cffb2c414 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 24 Dec 2025 16:37:58 +0530 Subject: [PATCH 10/10] (chore) re-add newline in CI config file --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ebc28ac..9215688 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,3 +28,4 @@ include: - project: "e/infra/ecloud/nextcloud-apps/ci-templates" ref: main file: "nc-publish-app.yml" + -- GitLab