ClearCollectionsAccessCache.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Repair\NC16;
  8. use OC\Collaboration\Resources\Manager;
  9. use OCP\Collaboration\Resources\IManager;
  10. use OCP\IConfig;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\IRepairStep;
  13. class ClearCollectionsAccessCache implements IRepairStep {
  14. /** @var IConfig */
  15. private $config;
  16. /** @var Manager */
  17. private $manager;
  18. public function __construct(IConfig $config, IManager $manager) {
  19. $this->config = $config;
  20. $this->manager = $manager;
  21. }
  22. public function getName(): string {
  23. return 'Clear access cache of projects';
  24. }
  25. private function shouldRun(): bool {
  26. $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
  27. return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<=');
  28. }
  29. public function run(IOutput $output): void {
  30. if ($this->shouldRun()) {
  31. $this->manager->invalidateAccessCacheForAllCollections();
  32. }
  33. }
  34. }