Commit 60b75a6d authored by webchick's avatar webchick

Issue #2946889 by Wim Leers, jfussion, quietone, jofitz, heddn: Missing...

Issue #2946889 by Wim Leers, jfussion, quietone, jofitz, heddn: Missing migration filters that are replaced with filter_null may have invalid settings applied
parent fb65f06c
......@@ -77,11 +77,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
else {
$fallback = $this->filterManager->getFallbackPluginId($plugin_id);
$message = $this->t('Filter @plugin_id could not be mapped to an existing filter plugin; defaulting to @fallback.', [
'@plugin_id' => $plugin_id,
'@fallback' => $fallback,
]);
$migrate_executable->saveMessage((string) $message, MigrationInterface::MESSAGE_WARNING);
// @see \Drupal\filter\Plugin\migrate\process\FilterSettings::transform()
$message = sprintf('Filter %s could not be mapped to an existing filter plugin; defaulting to %s and dropping all settings. Either redo the migration with the module installed that provides an equivalent filter, or modify the text format after the migration to remove this filter if it is no longer necessary.', $plugin_id, $fallback);
$migrate_executable->saveMessage($message, MigrationInterface::MESSAGE_WARNING);
return $fallback;
}
......
......@@ -46,6 +46,16 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$value['allowed_html'] = str_replace(array_keys($this->allowedHtmlDefaultAttributes), array_values($this->allowedHtmlDefaultAttributes), $value['allowed_html']);
}
}
// Filters that don't exist in Drupal 8 will have been mapped to filter_null
// but will have their settings (if any) retained. Those filter settings
// need to be dropped, otherwise saving the resulting FilterFormat config
// entity will be unable to save due to config schema validation errors.
// The migration warning message in the "filter_id" migration process plugin
// warns the user about this.
// @see \Drupal\filter\Plugin\migrate\process\FilterID::transform()
elseif ($row->getDestinationProperty('id') === 'filter_null') {
$value = [];
}
return $value;
}
......
......@@ -66,7 +66,7 @@ public function testTransform($value, $expected_value, $invalid_id = NULL) {
->expects($this->exactly(1))
->method('saveMessage')
->with(
'Filter ' . $invalid_id . ' could not be mapped to an existing filter plugin; defaulting to filter_null.',
sprintf('Filter %s could not be mapped to an existing filter plugin; defaulting to %s and dropping all settings. Either redo the migration with the module installed that provides an equivalent filter, or modify the text format after the migration to remove this filter if it is no longer necessary.', $invalid_id, $expected_value),
MigrationInterface::MESSAGE_WARNING
);
}
......
......@@ -96,6 +96,13 @@ public function dataProvider() {
'allowed_html' => '<a href hreflang> <em> <strong> <cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>',
],
],
[
[
'foo' => 'bar',
],
'filter_null',
[],
],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment