|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | +/** |
| 4 | + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
| 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, '16.0.4.2', '<='); |
| 51 | + } |
| 52 | + |
| 53 | + public function run(IOutput $output): void { |
| 54 | + if ($this->shouldRun()) { |
| 55 | + $this->manager->invalidateAccessCacheForAllCollections(); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments