diff --git a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php index cdef6ce..aa74736 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php +++ b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php @@ -35,7 +35,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable } $new_value = NestedArray::getValue($this->configuration['map'], $new_value, $key_exists); if (!$key_exists) { - if (isset($this->configuration['default_value'])) { + if (array_key_exists('default_value', $this->configuration)) { if (!empty($this->configuration['bypass'])) { throw new MigrateException('Setting both default_value and bypass is invalid.'); } diff --git a/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php b/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php index ee3a62b..59db2e5 100644 --- a/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php +++ b/core/modules/migrate/tests/src/Unit/process/StaticMapTest.php @@ -66,6 +66,17 @@ public function testMapWithInvalidSourceWithADefaultValue() { } /** + * Tests when the source is invalid but there's a default value of NULL. + */ + public function testMapWithInvalidSourceWithANullDefaultValue() { + $configuration['map']['foo']['bar'] = 'baz'; + $configuration['default_value'] = NULL; + $this->plugin = new StaticMap($configuration, 'map', []); + $value = $this->plugin->transform(array('bar'), $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertNull($value); + } + + /** * Tests when the source is invalid and bypass is enabled. * * @expectedException \Drupal\migrate\MigrateException