aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Repair/AddAppConfigLazyMigration.php
blob: 7ae83e8766940b93a6a62c85a8d4eb22b5c048ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OC\Repair;

use OCP\IAppConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;

class AddAppConfigLazyMigration implements IRepairStep {
	/**
	 * Just add config values that needs to be migrated to lazy loading
	 */
	private static array $lazyAppConfig = [
		'core' => [
			'oc.integritycheck.checker',
		],
	];

	public function __construct(
		private IAppConfig $appConfig,
		private LoggerInterface $logger,
	) {
	}

	public function getName() {
		return 'migrate lazy config values';
	}

	public function run(IOutput $output) {
		$c = 0;
		foreach (self::$lazyAppConfig as $appId => $configKeys) {
			foreach ($configKeys as $configKey) {
				$c += (int)$this->appConfig->updateLazy($appId, $configKey, true);
			}
		}

		$this->logger->notice('core/BackgroundJobs/AppConfigLazyMigration: ' . $c . ' config values updated');
	}
}