1
0

Version011901Date20240305120000.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
  5. *
  6. * @author Ferdinand Thiessen <opensource@fthiessen.de>
  7. *
  8. * @license AGPL-3.0-or-later
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\UpdateNotification\Migration;
  25. use OCA\UpdateNotification\BackgroundJob\ResetToken;
  26. use OCP\BackgroundJob\IJobList;
  27. use OCP\Migration\IOutput;
  28. use OCP\Migration\SimpleMigrationStep;
  29. /**
  30. * Drop this with Nextcloud 30
  31. */
  32. class Version011901Date20240305120000 extends SimpleMigrationStep {
  33. public function __construct(
  34. private IJobList $joblist,
  35. ) {
  36. }
  37. public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
  38. /**
  39. * Remove and replace the reset-updater-token background job
  40. * This class was renamed so it is now unknow but we still need to remove it
  41. * @psalm-suppress UndefinedClass, InvalidArgument
  42. */
  43. $hasOldResetToken = $this->joblist->has(\OCA\UpdateNotification\ResetTokenBackgroundJob::class, null);
  44. $hasNewResetToken = $this->joblist->has(ResetToken::class, null);
  45. if ($hasOldResetToken) {
  46. /**
  47. * @psalm-suppress UndefinedClass, InvalidArgument
  48. */
  49. $this->joblist->remove(\OCA\UpdateNotification\ResetTokenBackgroundJob::class);
  50. if (!$hasNewResetToken) {
  51. $this->joblist->add(ResetToken::class);
  52. }
  53. }
  54. /**
  55. * Remove the "has updates" background job, the new one is automatically started from the info.xml
  56. * @psalm-suppress UndefinedClass, InvalidArgument
  57. */
  58. if ($this->joblist->has(\OCA\UpdateNotification\Notification\BackgroundJob::class, null)) {
  59. /**
  60. * @psalm-suppress UndefinedClass, InvalidArgument
  61. */
  62. $this->joblist->remove(\OCA\UpdateNotification\Notification\BackgroundJob::class);
  63. }
  64. }
  65. }