From 40ae1295e6bd2414cf2716b79e2d4a74cb4bd2d5 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 5 Mar 2024 11:55:20 +0100 Subject: fix(updatenotification): Add migration step to replace and remove renamed background jobs This can be dropped with Nextcloud 30. Signed-off-by: Ferdinand Thiessen --- apps/updatenotification/appinfo/info.xml | 2 +- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + .../Migration/Version011901Date20240305120000.php | 73 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 apps/updatenotification/lib/Migration/Version011901Date20240305120000.php (limited to 'apps/updatenotification') diff --git a/apps/updatenotification/appinfo/info.xml b/apps/updatenotification/appinfo/info.xml index dc150962786..dd26d152966 100644 --- a/apps/updatenotification/appinfo/info.xml +++ b/apps/updatenotification/appinfo/info.xml @@ -5,7 +5,7 @@ Update notification Displays update notifications for Nextcloud, app updates, and provides the SSO for the updater. Displays update notifications for Nextcloud, app updates, and provides the SSO for the updater. - 1.19.0 + 1.19.1 agpl Lukas Reschke UpdateNotification diff --git a/apps/updatenotification/composer/composer/autoload_classmap.php b/apps/updatenotification/composer/composer/autoload_classmap.php index a03003ef3b2..4aa401f661e 100644 --- a/apps/updatenotification/composer/composer/autoload_classmap.php +++ b/apps/updatenotification/composer/composer/autoload_classmap.php @@ -18,6 +18,7 @@ return array( 'OCA\\UpdateNotification\\Listener\\AppUpdateEventListener' => $baseDir . '/../lib/Listener/AppUpdateEventListener.php', 'OCA\\UpdateNotification\\Listener\\BeforeTemplateRenderedEventListener' => $baseDir . '/../lib/Listener/BeforeTemplateRenderedEventListener.php', 'OCA\\UpdateNotification\\Manager' => $baseDir . '/../lib/Manager.php', + 'OCA\\UpdateNotification\\Migration\\Version011901Date20240305120000' => $baseDir . '/../lib/Migration/Version011901Date20240305120000.php', 'OCA\\UpdateNotification\\Notification\\AppUpdateNotifier' => $baseDir . '/../lib/Notification/AppUpdateNotifier.php', 'OCA\\UpdateNotification\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', 'OCA\\UpdateNotification\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php', diff --git a/apps/updatenotification/composer/composer/autoload_static.php b/apps/updatenotification/composer/composer/autoload_static.php index 57eedf5e075..9e1fdd09def 100644 --- a/apps/updatenotification/composer/composer/autoload_static.php +++ b/apps/updatenotification/composer/composer/autoload_static.php @@ -33,6 +33,7 @@ class ComposerStaticInitUpdateNotification 'OCA\\UpdateNotification\\Listener\\AppUpdateEventListener' => __DIR__ . '/..' . '/../lib/Listener/AppUpdateEventListener.php', 'OCA\\UpdateNotification\\Listener\\BeforeTemplateRenderedEventListener' => __DIR__ . '/..' . '/../lib/Listener/BeforeTemplateRenderedEventListener.php', 'OCA\\UpdateNotification\\Manager' => __DIR__ . '/..' . '/../lib/Manager.php', + 'OCA\\UpdateNotification\\Migration\\Version011901Date20240305120000' => __DIR__ . '/..' . '/../lib/Migration/Version011901Date20240305120000.php', 'OCA\\UpdateNotification\\Notification\\AppUpdateNotifier' => __DIR__ . '/..' . '/../lib/Notification/AppUpdateNotifier.php', 'OCA\\UpdateNotification\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', 'OCA\\UpdateNotification\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php', 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 @@ + + * + * @author Ferdinand Thiessen + * + * @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 . + * + */ + +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); + } + } +} -- cgit v1.2.3