1
0

Version011901Date20240305120000.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\UpdateNotification\Migration;
  8. use OCA\UpdateNotification\BackgroundJob\ResetToken;
  9. use OCA\UpdateNotification\Notification\BackgroundJob;
  10. use OCA\UpdateNotification\ResetTokenBackgroundJob;
  11. use OCP\BackgroundJob\IJobList;
  12. use OCP\Migration\IOutput;
  13. use OCP\Migration\SimpleMigrationStep;
  14. /**
  15. * Drop this with Nextcloud 30
  16. */
  17. class Version011901Date20240305120000 extends SimpleMigrationStep {
  18. public function __construct(
  19. private IJobList $joblist,
  20. ) {
  21. }
  22. public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
  23. /**
  24. * Remove and replace the reset-updater-token background job
  25. * This class was renamed so it is now unknow but we still need to remove it
  26. * @psalm-suppress UndefinedClass, InvalidArgument
  27. */
  28. $hasOldResetToken = $this->joblist->has(ResetTokenBackgroundJob::class, null);
  29. $hasNewResetToken = $this->joblist->has(ResetToken::class, null);
  30. if ($hasOldResetToken) {
  31. /**
  32. * @psalm-suppress UndefinedClass, InvalidArgument
  33. */
  34. $this->joblist->remove(ResetTokenBackgroundJob::class);
  35. if (!$hasNewResetToken) {
  36. $this->joblist->add(ResetToken::class);
  37. }
  38. }
  39. /**
  40. * Remove the "has updates" background job, the new one is automatically started from the info.xml
  41. * @psalm-suppress UndefinedClass, InvalidArgument
  42. */
  43. if ($this->joblist->has(BackgroundJob::class, null)) {
  44. /**
  45. * @psalm-suppress UndefinedClass, InvalidArgument
  46. */
  47. $this->joblist->remove(BackgroundJob::class);
  48. }
  49. }
  50. }