Skip to content
Snippets Groups Projects
Commit ef39eed7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2613178 by mikeryan, heddn: default_value: null in static map skips empty rows

parent e8322e4f
No related branches found
No related tags found
No related merge requests found
......@@ -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.');
}
......
......@@ -65,6 +65,17 @@ public function testMapWithInvalidSourceWithADefaultValue() {
$this->assertSame($value, 'test');
}
/**
* 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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment