Passed
Push — master ( 182517...f88e95 )
by Roeland
11:13 queued 11s
created

ClearCollectionsAccessCache::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2019 Joas Schilling <[email protected]>
5
 *
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OC\Repair\NC16;
24
25
use OC\Collaboration\Resources\Manager;
26
use OCP\Collaboration\Resources\IManager;
27
use OCP\IConfig;
28
use OCP\Migration\IOutput;
29
use OCP\Migration\IRepairStep;
30
31
class ClearCollectionsAccessCache implements IRepairStep {
32
33
	/** @var IConfig */
34
	private $config;
35
36
	/** @var IManager|Manager */
37
	private $manager;
38
39
	public function __construct(IConfig $config, IManager $manager) {
40
		$this->config = $config;
41
		$this->manager = $manager;
42
	}
43
44
	public function getName(): string {
45
		return 'Clear access cache of projects';
46
	}
47
48
	private function shouldRun(): bool {
49
		$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
50
		return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<=');
51
	}
52
53
	public function run(IOutput $output): void {
54
		if ($this->shouldRun()) {
55
			$this->manager->invalidateAccessCacheForAllCollections();
0 ignored issues
show
Bug introduced by
The method invalidateAccessCacheForAllCollections() does not exist on OCP\Collaboration\Resources\IManager. Did you maybe mean invalidateAccessCacheForUser()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
			$this->manager->/** @scrutinizer ignore-call */ 
56
                   invalidateAccessCacheForAllCollections();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
		}
57
	}
58
}
59