AddAppConfigLazyMigration.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Repair;
  8. use OCP\IAppConfig;
  9. use OCP\Migration\IOutput;
  10. use OCP\Migration\IRepairStep;
  11. use Psr\Log\LoggerInterface;
  12. class AddAppConfigLazyMigration implements IRepairStep {
  13. /**
  14. * Just add config values that needs to be migrated to lazy loading
  15. */
  16. private static array $lazyAppConfig = [
  17. 'core' => [
  18. 'oc.integritycheck.checker',
  19. ],
  20. ];
  21. public function __construct(
  22. private IAppConfig $appConfig,
  23. private LoggerInterface $logger,
  24. ) {
  25. }
  26. public function getName() {
  27. return 'migrate lazy config values';
  28. }
  29. public function run(IOutput $output) {
  30. $c = 0;
  31. foreach (self::$lazyAppConfig as $appId => $configKeys) {
  32. foreach ($configKeys as $configKey) {
  33. $c += (int)$this->appConfig->updateLazy($appId, $configKey, true);
  34. }
  35. }
  36. $this->logger->notice('core/BackgroundJobs/AppConfigLazyMigration: ' . $c . ' config values updated');
  37. }
  38. }