diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-03-05 11:55:20 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2024-03-07 22:40:30 +0100 |
commit | 40ae1295e6bd2414cf2716b79e2d4a74cb4bd2d5 (patch) | |
tree | edcf808f37f2919a5f4e1c43d67cd2ea9e5b8347 /apps/updatenotification/lib | |
parent | 31d24a5538e7773b862a7ffe6ad7abb0002979b1 (diff) | |
download | nextcloud-server-40ae1295e6bd2414cf2716b79e2d4a74cb4bd2d5.tar.gz nextcloud-server-40ae1295e6bd2414cf2716b79e2d4a74cb4bd2d5.zip |
fix(updatenotification): Add migration step to replace and remove renamed background jobs
This can be dropped with Nextcloud 30.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/updatenotification/lib')
-rw-r--r-- | apps/updatenotification/lib/Migration/Version011901Date20240305120000.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php b/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php new file mode 100644 index 00000000000..283228fcb76 --- /dev/null +++ b/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de> + * + * @author Ferdinand Thiessen <opensource@fthiessen.de> + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\UpdateNotification\Migration; + +use OCA\UpdateNotification\BackgroundJob\ResetToken; +use OCP\BackgroundJob\IJobList; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Drop this with Nextcloud 30 + */ +class Version011901Date20240305120000 extends SimpleMigrationStep { + + public function __construct( + private IJobList $joblist, + ) { + } + + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { + /** + * Remove and replace the reset-updater-token background job + * This class was renamed so it is now unknow but we still need to remove it + * @psalm-suppress UndefinedClass, InvalidArgument + */ + $hasOldResetToken = $this->joblist->has(\OCA\UpdateNotification\ResetTokenBackgroundJob::class, null); + $hasNewResetToken = $this->joblist->has(ResetToken::class, null); + if ($hasOldResetToken) { + /** + * @psalm-suppress UndefinedClass, InvalidArgument + */ + $this->joblist->remove(\OCA\UpdateNotification\ResetTokenBackgroundJob::class); + if (!$hasNewResetToken) { + $this->joblist->add(ResetToken::class); + } + } + + /** + * Remove the "has updates" background job, the new one is automatically started from the info.xml + * @psalm-suppress UndefinedClass, InvalidArgument + */ + if ($this->joblist->has(\OCA\UpdateNotification\Notification\BackgroundJob::class, null)) { + /** + * @psalm-suppress UndefinedClass, InvalidArgument + */ + $this->joblist->remove(\OCA\UpdateNotification\Notification\BackgroundJob::class); + } + } +} |