diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml index 6f17473623d6d..2dd3d21c47ef1 100644 --- a/apps/dav/appinfo/info.xml +++ b/apps/dav/appinfo/info.xml @@ -47,6 +47,9 @@ OCA\DAV\Migration\RemoveOrphanEventsAndContacts OCA\DAV\Migration\RemoveClassifiedEventActivity OCA\DAV\Migration\RemoveDeletedUsersCalendarSubscriptions + + OCA\DAV\Migration\DeleteSchedulingObjects + OCA\DAV\Migration\RemoveObjectProperties OCA\DAV\Migration\ChunkCleanup diff --git a/apps/dav/lib/Migration/DeleteSchedulingObjects.php b/apps/dav/lib/Migration/DeleteSchedulingObjects.php index 3cb3c9c9b109b..00d8b4cc28d17 100644 --- a/apps/dav/lib/Migration/DeleteSchedulingObjects.php +++ b/apps/dav/lib/Migration/DeleteSchedulingObjects.php @@ -13,9 +13,9 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\Migration\IOutput; -use OCP\Migration\IRepairStep; +use OCP\Migration\IRepairStepExpensive; -class DeleteSchedulingObjects implements IRepairStep { +class DeleteSchedulingObjects implements IRepairStepExpensive { public function __construct( private IJobList $jobList, private ITimeFactory $time, diff --git a/apps/dav/lib/Migration/RemoveObjectProperties.php b/apps/dav/lib/Migration/RemoveObjectProperties.php index 8304accb51cac..18220353cc316 100644 --- a/apps/dav/lib/Migration/RemoveObjectProperties.php +++ b/apps/dav/lib/Migration/RemoveObjectProperties.php @@ -9,9 +9,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\Migration\IOutput; -use OCP\Migration\IRepairStep; +use OCP\Migration\IRepairStepExpensive; -class RemoveObjectProperties implements IRepairStep { +class RemoveObjectProperties implements IRepairStepExpensive { private const RESOURCE_TYPE_PROPERTY = '{DAV:}resourcetype'; private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card'; private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp'; diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index f34f4dc0b9af5..898133cfdc49e 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -42,6 +42,8 @@ Turning the feature off removes shared files and folders on the server for all s OCA\Files_Sharing\Migration\OwncloudGuestShareType OCA\Files_Sharing\Migration\SetPasswordColumn OCA\Files_Sharing\Migration\SetAcceptedStatus + + OCA\Files_Sharing\Repair\CleanupShareTarget diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php index 84bfe0b4cb3e4..7b5959871c982 100644 --- a/core/Command/Maintenance/Repair.php +++ b/core/Command/Maintenance/Repair.php @@ -51,14 +51,11 @@ protected function configure(): void { } protected function execute(InputInterface $input, OutputInterface $output): int { - $repairSteps = $this->repair::getRepairSteps(); - - if ($input->getOption('include-expensive')) { - $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps()); - } + $includeExpensive = (bool)$input->getOption('include-expensive'); + $repairSteps = $this->repair::getRepairSteps($includeExpensive); foreach ($repairSteps as $step) { - $this->repair->addStep($step); + $this->repair->addStep($step, $includeExpensive); } $apps = $this->appManager->getEnabledApps(); @@ -74,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $steps = $info['repair-steps']['post-migration']; foreach ($steps as $step) { try { - $this->repair->addStep($step); + $this->repair->addStep($step, $includeExpensive); } catch (Exception $ex) { $output->writeln("Failed to load repair step for $app: {$ex->getMessage()}"); } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 86f42be19766b..6d57f1e487842 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -712,6 +712,7 @@ 'OCP\\Migration\\IMigrationStep' => $baseDir . '/lib/public/Migration/IMigrationStep.php', 'OCP\\Migration\\IOutput' => $baseDir . '/lib/public/Migration/IOutput.php', 'OCP\\Migration\\IRepairStep' => $baseDir . '/lib/public/Migration/IRepairStep.php', + 'OCP\\Migration\\IRepairStepExpensive' => $baseDir . '/lib/public/Migration/IRepairStepExpensive.php', 'OCP\\Migration\\SimpleMigrationStep' => $baseDir . '/lib/public/Migration/SimpleMigrationStep.php', 'OCP\\Navigation\\Events\\LoadAdditionalEntriesEvent' => $baseDir . '/lib/public/Navigation/Events/LoadAdditionalEntriesEvent.php', 'OCP\\Notification\\AlreadyProcessedException' => $baseDir . '/lib/public/Notification/AlreadyProcessedException.php', @@ -2061,7 +2062,7 @@ 'OC\\Repair\\MoveUpdaterStepFile' => $baseDir . '/lib/private/Repair/MoveUpdaterStepFile.php', 'OC\\Repair\\NC13\\AddLogRotateJob' => $baseDir . '/lib/private/Repair/NC13/AddLogRotateJob.php', 'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => $baseDir . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php', - 'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php', + 'OC\\Repair\\NC16\\AddCleanupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php', 'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php', 'OC\\Repair\\NC16\\ClearCollectionsAccessCache' => $baseDir . '/lib/private/Repair/NC16/ClearCollectionsAccessCache.php', 'OC\\Repair\\NC18\\ResetGeneratedAvatarFlag' => $baseDir . '/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 65bf26baf5cf2..564995dbfa757 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -753,6 +753,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Migration\\IMigrationStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IMigrationStep.php', 'OCP\\Migration\\IOutput' => __DIR__ . '/../../..' . '/lib/public/Migration/IOutput.php', 'OCP\\Migration\\IRepairStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IRepairStep.php', + 'OCP\\Migration\\IRepairStepExpensive' => __DIR__ . '/../../..' . '/lib/public/Migration/IRepairStepExpensive.php', 'OCP\\Migration\\SimpleMigrationStep' => __DIR__ . '/../../..' . '/lib/public/Migration/SimpleMigrationStep.php', 'OCP\\Navigation\\Events\\LoadAdditionalEntriesEvent' => __DIR__ . '/../../..' . '/lib/public/Navigation/Events/LoadAdditionalEntriesEvent.php', 'OCP\\Notification\\AlreadyProcessedException' => __DIR__ . '/../../..' . '/lib/public/Notification/AlreadyProcessedException.php', @@ -2102,7 +2103,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Repair\\MoveUpdaterStepFile' => __DIR__ . '/../../..' . '/lib/private/Repair/MoveUpdaterStepFile.php', 'OC\\Repair\\NC13\\AddLogRotateJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/AddLogRotateJob.php', 'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php', - 'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php', + 'OC\\Repair\\NC16\\AddCleanupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php', 'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php', 'OC\\Repair\\NC16\\ClearCollectionsAccessCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/ClearCollectionsAccessCache.php', 'OC\\Repair\\NC18\\ResetGeneratedAvatarFlag' => __DIR__ . '/../../..' . '/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php', diff --git a/lib/private/Repair.php b/lib/private/Repair.php index e35feda335773..be6de73579c2d 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -29,7 +29,7 @@ use OC\Repair\MoveUpdaterStepFile; use OC\Repair\NC13\AddLogRotateJob; use OC\Repair\NC14\AddPreviewBackgroundCleanupJob; -use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob; +use OC\Repair\NC16\AddCleanupLoginFlowV2BackgroundJob; use OC\Repair\NC16\CleanupCardDAVPhotoCache; use OC\Repair\NC16\ClearCollectionsAccessCache; use OC\Repair\NC18\ResetGeneratedAvatarFlag; @@ -56,14 +56,12 @@ use OC\Repair\RepairInvalidShares; use OC\Repair\RepairLogoDimension; use OC\Repair\RepairMimeTypes; -use OCA\DAV\Migration\DeleteSchedulingObjects; -use OCA\DAV\Migration\RemoveObjectProperties; -use OCA\Files_Sharing\Repair\CleanupShareTarget; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use OCP\Migration\IRepairStepExpensive; use OCP\Server; use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; @@ -113,10 +111,11 @@ public function run(): void { /** * Add repair step * - * @param IRepairStep|class-string $repairStep repair step + * @param IRepairStep|class-string $repairStep Repair step + * @param bool $includeExpensive Whether to include expensive repair steps, defaults to false * @throws \Exception */ - public function addStep(IRepairStep|string $repairStep): void { + public function addStep(IRepairStep|string $repairStep, bool $includeExpensive = false): void { if (is_string($repairStep)) { try { $s = Server::get($repairStep); @@ -134,24 +133,30 @@ public function addStep(IRepairStep|string $repairStep): void { } } - if ($s instanceof IRepairStep) { - $this->repairSteps[] = $s; - } else { + if (!($s instanceof IRepairStep)) { throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); } + + $repairStep = $s; + } + + if (($repairStep instanceof IRepairStepExpensive) && !$includeExpensive) { + $this->debug("Skipping expensive repair step '" . $repairStep::class . "'"); } else { $this->repairSteps[] = $repairStep; } } /** - * Returns the default repair steps to be run on the - * command line or after an upgrade. + * Returns the core repair steps to be run on the command line or after an upgrade. * + * @param bool $includeExpensive Whether to include expensive repair steps, defaults to false * @return list + * + * @since 34.0.0, the $includeExpensive parameter was added */ - public static function getRepairSteps(): array { - return [ + public static function getRepairSteps(bool $includeExpensive = false): array { + $repairSteps = [ new Collation(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(IDBConnection::class), false), Server::get(CleanTags::class), Server::get(RepairInvalidShares::class), @@ -167,7 +172,7 @@ public static function getRepairSteps(): array { Server::get(AddPreviewBackgroundCleanupJob::class), Server::get(AddCleanupUpdaterBackupsJob::class), Server::get(CleanupCardDAVPhotoCache::class), - Server::get(AddClenupLoginFlowV2BackgroundJob::class), + Server::get(AddCleanupLoginFlowV2BackgroundJob::class), Server::get(RemoveLinkShares::class), Server::get(ClearCollectionsAccessCache::class), Server::get(ResetGeneratedAvatarFlag::class), @@ -190,28 +195,17 @@ public static function getRepairSteps(): array { Server::get(AddMovePreviewJob::class), Server::get(ConfigKeyMigration::class), ]; - } - - /** - * Returns expensive repair steps to be run on the - * command line with a special option. - * - * @return list - */ - public static function getExpensiveRepairSteps(): array { - $expensiveSteps = [ - Server::get(OldGroupMembershipShares::class), - Server::get(RemoveBrokenProperties::class), - Server::get(RepairMimeTypes::class), - Server::get(DeleteSchedulingObjects::class), - Server::get(RemoveObjectProperties::class), - ]; - if (class_exists(CleanupShareTarget::class)) { - $expensiveSteps[] = Server::get(CleanupShareTarget::class); + if ($includeExpensive) { + $expensiveSteps = [ + Server::get(OldGroupMembershipShares::class), + Server::get(RemoveBrokenProperties::class), + Server::get(RepairMimeTypes::class), + ]; + $repairSteps = array_merge($repairSteps, $expensiveSteps); } - return $expensiveSteps; + return $repairSteps; } /** diff --git a/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php b/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php similarity index 89% rename from lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php rename to lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php index 50dd0050fe14e..630b20a4128b7 100644 --- a/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php +++ b/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php @@ -13,7 +13,7 @@ use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -class AddClenupLoginFlowV2BackgroundJob implements IRepairStep { +class AddCleanupLoginFlowV2BackgroundJob implements IRepairStep { public function __construct( private IJobList $jobList, ) { diff --git a/lib/public/Migration/IRepairStepExpensive.php b/lib/public/Migration/IRepairStepExpensive.php new file mode 100644 index 0000000000000..0f954c3eade24 --- /dev/null +++ b/lib/public/Migration/IRepairStepExpensive.php @@ -0,0 +1,20 @@ +