diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-02-24 14:52:24 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-02-24 16:44:49 +0100 |
commit | d3dbe3ab2c14760d4801c1167dc78d55943b9ebe (patch) | |
tree | 970dbe3bd517222ca2e797d8a8a9308d05193f96 /lib/private/Repair | |
parent | bb73628ebeeb2e4adb2d90df3c7543e420ba0524 (diff) | |
download | nextcloud-server-d3dbe3ab2c14760d4801c1167dc78d55943b9ebe.tar.gz nextcloud-server-d3dbe3ab2c14760d4801c1167dc78d55943b9ebe.zip |
refactor: convert sanitize account properties repair step to background jobbackport/50985/stable30
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib/private/Repair')
-rw-r--r-- | lib/private/Repair/NC29/SanitizeAccountProperties.php | 30 | ||||
-rw-r--r-- | lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php (renamed from lib/private/Repair/NC29/ValidateAccountProperties.php) | 17 |
2 files changed, 38 insertions, 9 deletions
diff --git a/lib/private/Repair/NC29/SanitizeAccountProperties.php b/lib/private/Repair/NC29/SanitizeAccountProperties.php new file mode 100644 index 00000000000..412570ba71d --- /dev/null +++ b/lib/private/Repair/NC29/SanitizeAccountProperties.php @@ -0,0 +1,30 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OC\Repair\NC29; + +use OCP\BackgroundJob\IJobList; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class SanitizeAccountProperties implements IRepairStep { + + public function __construct( + private IJobList $jobList, + ) { + } + + public function getName(): string { + return 'Validate account properties and store phone numbers in a known format for search'; + } + + public function run(IOutput $output): void { + $this->jobList->add(SanitizeAccountPropertiesJob::class, null); + $output->info('Queued background to validate account properties.'); + } +} diff --git a/lib/private/Repair/NC29/ValidateAccountProperties.php b/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php index 640cd678ba0..55ec445e9da 100644 --- a/lib/private/Repair/NC29/ValidateAccountProperties.php +++ b/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php @@ -10,13 +10,13 @@ namespace OC\Repair\NC29; use InvalidArgumentException; use OCP\Accounts\IAccountManager; +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\QueuedJob; use OCP\IUser; use OCP\IUserManager; -use OCP\Migration\IOutput; -use OCP\Migration\IRepairStep; use Psr\Log\LoggerInterface; -class ValidateAccountProperties implements IRepairStep { +class SanitizeAccountPropertiesJob extends QueuedJob { private const PROPERTIES_TO_CHECK = [ IAccountManager::PROPERTY_PHONE, @@ -26,17 +26,16 @@ class ValidateAccountProperties implements IRepairStep { ]; public function __construct( + ITimeFactory $timeFactory, private IUserManager $userManager, private IAccountManager $accountManager, private LoggerInterface $logger, ) { + parent::__construct($timeFactory); + $this->setAllowParallelRuns(false); } - public function getName(): string { - return 'Validate account properties and store phone numbers in a known format for search'; - } - - public function run(IOutput $output): void { + protected function run(mixed $argument): void { $numRemoved = 0; $this->userManager->callForSeenUsers(function (IUser $user) use (&$numRemoved) { @@ -70,7 +69,7 @@ class ValidateAccountProperties implements IRepairStep { }); if ($numRemoved > 0) { - $output->info('Cleaned ' . $numRemoved . ' invalid account property entries'); + $this->logger->info('Cleaned ' . $numRemoved . ' invalid account property entries'); } } } |