Passed
Push — master ( e4dff7...06a1cf )
by Roeland
13:23 queued 01:40
created

RemoveRefreshTime   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 24
rs 10
c 1
b 0
f 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A run() 0 8 1
A getName() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2020 Arthur Schiwon <[email protected]>
6
 *
7
 * @author Arthur Schiwon <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OCA\User_LDAP\Migration;
27
28
use OCP\IConfig;
29
use OCP\IDBConnection;
30
use OCP\Migration\IOutput;
31
use OCP\Migration\IRepairStep;
32
33
/**
34
 * Class RmRefreshTime
35
 *
36
 * this can be removed with Nextcloud 21
37
 *
38
 * @package OCA\User_LDAP\Migration
39
 */
40
class RemoveRefreshTime implements IRepairStep {
41
42
	/** @var IDBConnection */
43
	private $dbc;
44
	/** @var IConfig */
45
	private $config;
46
47
	public function __construct(IDBConnection $dbc, IConfig $config) {
48
		$this->dbc = $dbc;
49
		$this->config = $config;
50
	}
51
52
	public function getName() {
53
		return 'Remove deprecated refresh time markers for LDAP user records';
54
	}
55
56
	public function run(IOutput $output) {
57
		$this->config->deleteAppValue('user_ldap', 'updateAttributesInterval');
58
59
		$qb = $this->dbc->getQueryBuilder();
60
		$qb->delete('preferences')
61
			->where($qb->expr()->eq('appid', $qb->createNamedParameter('user_ldap')))
62
			->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lastFeatureRefresh')))
63
			->execute();
64
	}
65
}
66