diff -u b/core/modules/filter/src/Plugin/migrate/process/FilterID.php b/core/modules/filter/src/Plugin/migrate/process/FilterID.php --- b/core/modules/filter/src/Plugin/migrate/process/FilterID.php +++ b/core/modules/filter/src/Plugin/migrate/process/FilterID.php @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\migrate\process\StaticMap; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,7 +20,7 @@ /** * The filter plugin manager. * - * @var \Drupal\Component\Plugin\PluginManagerInterface + * @var \Drupal\Component\Plugin\PluginManagerInterface|\Drupal\Component\Plugin\FallbackPluginManagerInterface */ protected $filterManager; @@ -58,14 +59,23 @@ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $plugin_id = parent::transform($value, $migrate_executable, $row, $destination_property); - // Try to create an instance of the filter to ensure that it actually - // exists. If it doesn't, the filter manager will create an instance of - // its fallback plugin, filter_null, whose constructor will set a helpful - // error message like "Unknown filter [original filter ID]". We'll let the - // invalid value pass through anyway, since the filter system will always - // fall back to filter_null and the user can deal with it later. - $this->filterManager->createInstance($plugin_id); - return $plugin_id; + if ($this->filterManager->hasDefinition($plugin_id)) { + return $plugin_id; + } + else { + $fallback = $this->filterManager->getFallbackPluginId($plugin_id); + + if (is_array($value)) { + $value = implode(', ', $value); + } + $message = $this->t('Filter @id could not be mapped to an existing filter plugin; defaulting to @fallback.', [ + '@id' => $value, + '@fallback' => $fallback, + ]); + $migrate_executable->saveMessage($message, MigrationInterface::MESSAGE_WARNING); + + return $fallback; + } } }