Issue #2886349 by quietone, PunamShelke, mikeryan, heddn: Invalid argument supplied for foreach() Migration.php:352

merge-requests/55/head
catch 2019-09-16 12:13:41 +01:00
parent 798ae0c796
commit b147d5e084
2 changed files with 21 additions and 0 deletions

View File

@ -363,6 +363,9 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
$this->processPlugins[$index] = [];
foreach ($this->getProcessNormalized($process) as $property => $configurations) {
$this->processPlugins[$index][$property] = [];
if (!is_array($configurations) && !$this->processPlugins[$index][$property]) {
throw new MigrateException(sprintf("Process configuration for '$property' must be an array", $property));
}
foreach ($configurations as $configuration) {
if (isset($configuration['source'])) {
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance('get', $configuration, $this);

View File

@ -41,6 +41,24 @@ class MigrationTest extends KernelTestBase {
$migration->getProcessPlugins(['foobar' => ['plugin' => 'get']]);
}
/**
* Tests Migration::getDestinationPlugin()
*
* @covers ::getDestinationPlugin
*/
public function testGetProcessPluginsExceptionMessage() {
// Test with an invalid process pipeline.
$plugin_definition = [
'process' => [
'dest1' => 123,
],
];
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($plugin_definition);
$this->expectException(MigrateException::class);
$this->expectExceptionMessage("Process configuration for 'dest1' must be an array");
$migration->getProcessPlugins();
}
/**
* Tests Migration::getMigrationDependencies()
*