Skip to content

Commit c4da16e

Browse files
author
Nathaniel Catchpole
committed
Issue #3023747 by mikelutz, heddn: D6 profile migrations assume stubs, which fail
(cherry picked from commit 95b3b17)
1 parent 07c88d0 commit c4da16e

File tree

3 files changed

+90
-5
lines changed

3 files changed

+90
-5
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
4+
5+
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
6+
7+
/**
8+
* Tests the getProcess() method of all Drupal 6 migrations.
9+
*
10+
* @group migrate_drupal
11+
*/
12+
class MigrationProcessTest extends MigrateDrupal6TestBase {
13+
use FileSystemModuleDiscoveryDataProviderTrait;
14+
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function setUp() {
19+
self::$modules = array_keys($this->coreModuleListDataProvider());
20+
parent::setUp();
21+
}
22+
23+
/**
24+
* Tests that calling getProcess() on a migration does not throw an exception.
25+
*
26+
* @throws \Exception
27+
*/
28+
public function testGetProcess() {
29+
/** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager */
30+
$plugin_manager = $this->container->get('plugin.manager.migration');
31+
$migrations = $plugin_manager->createInstancesByTag('Drupal 6');
32+
foreach ($migrations as $migration) {
33+
try {
34+
$process = $migration->getProcess();
35+
}
36+
catch (\Exception $e) {
37+
$this->fail(sprintf("Migration %s process failed with error: %s", $migration->label(), $e->getMessage()));
38+
}
39+
$this->assertNotNull($process);
40+
}
41+
}
42+
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Drupal\Tests\migrate_drupal\Kernel\d7;
4+
5+
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
6+
7+
/**
8+
* Tests the getProcess() method of all Drupal 7 migrations.
9+
*
10+
* @group migrate_drupal
11+
*/
12+
class MigrationProcessTest extends MigrateDrupal7TestBase {
13+
use FileSystemModuleDiscoveryDataProviderTrait;
14+
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function setUp() {
19+
self::$modules = array_keys($this->coreModuleListDataProvider());
20+
parent::setUp();
21+
}
22+
23+
/**
24+
* Tests that calling getProcess() on a migration does not throw an exception.
25+
*
26+
* @throws \Exception
27+
*/
28+
public function testGetProcess() {
29+
/** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager */
30+
$plugin_manager = $this->container->get('plugin.manager.migration');
31+
$migrations = $plugin_manager->createInstancesByTag('Drupal 7');
32+
foreach ($migrations as $migration) {
33+
try {
34+
$process = $migration->getProcess();
35+
}
36+
catch (\Exception $e) {
37+
$this->fail(sprintf("Migration %s process failed with error: %s", $migration->label(), $e->getMessage()));
38+
}
39+
$this->assertNotNull($process);
40+
}
41+
}
42+
43+
}

modules/user/src/Plugin/migrate/ProfileValues.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Drupal\migrate\Exception\RequirementsException;
66
use Drupal\migrate\MigrateExecutable;
7-
use Drupal\migrate\MigrateSkipRowException;
87
use Drupal\migrate\Plugin\Migration;
98

109
/**
@@ -32,6 +31,7 @@ public function getProcess() {
3231
$definition['destination']['plugin'] = 'null';
3332
$definition['idMap']['plugin'] = 'null';
3433
try {
34+
$this->checkRequirements();
3535
$profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
3636
$migrate_executable = new MigrateExecutable($profile_field_migration);
3737
$source_plugin = $profile_field_migration->getSourcePlugin();
@@ -45,21 +45,20 @@ public function getProcess() {
4545
[
4646
'migration' => 'user_profile_field',
4747
'source_ids' => $fid,
48+
'no_stub' => TRUE,
4849
];
4950
$plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration);
5051
$new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp');
5152
if (isset($new_value[1])) {
5253
// Set the destination to the migrated profile field name.
5354
$this->process[$new_value[1]] = $name;
5455
}
55-
else {
56-
throw new MigrateSkipRowException("Can't migrate source field $name.");
57-
}
5856
}
5957
}
6058
catch (RequirementsException $e) {
6159
// The checkRequirements() call will fail when the profile module does
62-
// not exist on the source site.
60+
// not exist on the source site, or if the required migrations have not
61+
// yet run.
6362
}
6463
}
6564
return parent::getProcess();

0 commit comments

Comments
 (0)