Skip to content

Commit 885b790

Browse files
committed
Avoid passing both $importSource and $version while version comes from source
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 67fb1b9 commit 885b790

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

lib/public/UserMigration/IImportSource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public function copyToFolder(Folder $destination, string $sourcePath): bool;
7070
*/
7171
public function getMigratorVersions(): array;
7272

73+
/**
74+
* @return ?int Version for this migrator from the export archive. Null means migrator missing.
75+
*
76+
* @param class-string<IMigrator> $migrator
77+
*
78+
* @since 24.0.0
79+
*/
80+
public function getMigratorVersion(string $migrator): ?int;
81+
7382
/**
7483
* Called after import is complete
7584
*

lib/public/UserMigration/IMigrator.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function export(
5454
public function import(
5555
IUser $user,
5656
IImportSource $importSource,
57-
OutputInterface $output,
58-
?int $version
57+
OutputInterface $output
5958
): void;
6059

6160
/**
@@ -67,13 +66,11 @@ public function getVersion(): int;
6766

6867
/**
6968
* Checks whether it is able to import a version of the export format for this migrator
70-
*
71-
* @param ?int $version Version stored in the import source for this migrator. Null means this migrator was not listed.
69+
* Use $importSource->getMigratorVersion(static::class) to get the version from the archive
7270
*
7371
* @since 24.0.0
7472
*/
7573
public function canImport(
76-
IImportSource $importSource,
77-
?int $version
74+
IImportSource $importSource
7875
): bool;
7976
}

lib/public/UserMigration/TMigratorBasicVersionHandling.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function getVersion(): int {
4545
* {@inheritDoc}
4646
*/
4747
public function canImport(
48-
IImportSource $importSource,
49-
?int $version
48+
IImportSource $importSource
5049
): bool {
50+
$version = $importSource->getMigratorVersion(static::class);
5151
if ($version === null) {
5252
return !$this->mandatory;
5353
}

0 commit comments

Comments
 (0)