diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index 93db99c..ef5b86c 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -317,7 +317,6 @@ public function rollback() { // Loop through each row in the map, and try to roll it back. foreach ($id_map as $map_row) { $destination_key = $id_map->currentDestination(); - if ($destination_key) { $map_row = $id_map->getRowByDestination($destination_key); if ($map_row['rollback_action'] == MigrateIdMapInterface::ROLLBACK_DELETE) { @@ -331,7 +330,8 @@ public function rollback() { $id_map->deleteDestination($destination_key); } else { - // No destination key, import probably failed, remove row + // If there is no destination key the import probably failed and we can + // remove the row without further action. $source_key = $id_map->currentSource(); $id_map->delete($source_key); } diff --git a/core/modules/migrate/tests/src/Kernel/MigrateRollbackTest.php b/core/modules/migrate/tests/src/Kernel/MigrateRollbackTest.php index 9ec0c65..4b78e65 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateRollbackTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateRollbackTest.php @@ -128,6 +128,9 @@ public function testRollback() { $this->assertNotNull($map_row['destid1']); } + // Add a failed row to test if this can be rolled back without errors. + $this->mockFailure($term_migration, ['id' => '4', 'vocab' => '2', 'name' => 'FAIL']); + // Rollback and verify the entities are gone. $term_executable->rollback(); foreach ($term_data_rows as $row) {