diff -u b/core/modules/migrate/src/MigrateIdAuditor.php b/core/modules/migrate/src/MigrateIdAuditor.php --- b/core/modules/migrate/src/MigrateIdAuditor.php +++ b/core/modules/migrate/src/MigrateIdAuditor.php @@ -5,26 +5,15 @@ use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\migrate\Plugin\MigrateDestinationAuditInterface; use Drupal\migrate\Plugin\MigrateIdMapAuditInterface; +use Drupal\migrate\Plugin\MigrationInterface; /** * Audits a set of migrations for potential ID conflicts. */ -class MigrateIdAuditor { +class MigrateIdAuditor implements MigrateIdAuditorInterface { /** - * Audits a set of migrations for potential ID conflicts. - * - * ID conflicts exist if new content has been created without the migration - * system knowing about it. To find out if there is ID conflicts, this method - * should compare the highest destination ID to the highest migrated ID. If - * the former is greater than the later, there is ID conflicts. - * - * @param \Drupal\migrate\Plugin\MigrationInterface[] $migrations - * The set of migrations to audit. - * - * @return string[] - * The entity type IDs of migrated content that may have conflicting IDs. - * If no conflicts are found, an empty array will be returned. + * {@inheritdoc} */ public function auditIds(array $migrations) { $conflicts = []; @@ -36,20 +25,14 @@ if ($destination instanceof MigrateDestinationAuditInterface && $id_map instanceof MigrateIdMapAuditInterface) { $field_name = $destination->getAuditedIdFieldName(); if ($destination->getHighestDestinationId($field_name) > $id_map->getHighestMigratedId($field_name)) { - $base_id = $migration->getBaseId(); - $label = $migration->label(); - if (is_string($label)) { - $conflicts[$base_id] = $label; - } - elseif ($label instanceof TranslatableMarkup) { - $arguments = $label->getArguments(); - if (isset($arguments['@label'])) { - $conflicts[$base_id] = $arguments['@label']; - } - else { - $conflicts[$base_id] = $label->render(); - } - } + $conflicts += $this->buildConflict($migration); + } + elseif ($destination->isTranslationDestination()) { + // @TODO: Figure out how to determine if this will result in conflicts. + // Hint, I don't think this is possible by simply comparing highest id. + // For now, blindly warn it *is* a conflict, even though it very + // well might not. It would only effects term and node translation migrations. + $conflicts += $this->buildConflict($migration); } } } @@ -59,2 +42,26 @@ + /** + * Build conflict label. + * + * @param \Drupal\migrate\Plugin\MigrationInterface $migration + * + * @return array + */ + protected function buildConflict(MigrationInterface $migration) { + $conflict = []; + $base_id = $migration->getBaseId(); + $label = $migration->label(); + if (is_string($label)) { + $conflict[$base_id] = $label; + } + elseif ($label instanceof TranslatableMarkup) { + $conflict[$base_id] = $label->render(); + if (isset($label->getArguments()['@label'])) { + $conflict[$base_id] = $label->getArguments()['@label']; + } + } + + return $conflict; + } + } diff -u b/core/modules/migrate/src/Plugin/MigrateDestinationAuditInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationAuditInterface.php --- b/core/modules/migrate/src/Plugin/MigrateDestinationAuditInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateDestinationAuditInterface.php @@ -33,2 +33,10 @@ + /** + * Get whether this destination is for translations. + * + * @return bool + * Whether this destination is for translations. + */ + public function isTranslationDestination(); + } diff -u b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php --- b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -119,12 +119,9 @@ } /** - * Get whether this destination is for translations. - * - * @return bool - * Whether this destination is for translations. + * {@inheritdoc} */ - protected function isTranslationDestination() { + public function isTranslationDestination() { return !empty($this->configuration['translations']); } diff -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -8,7 +8,7 @@ use Drupal\Core\Render\RendererInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Url; -use Drupal\migrate\MigrateIdAuditor; +use Drupal\migrate\MigrateIdAuditorInterface; use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch; use Drupal\migrate_drupal\MigrationConfigurationTrait; @@ -52,7 +52,7 @@ /** * The ID conflict auditor. * - * @var \Drupal\migrate\MigrateIdAuditor $idAuditor + * @var \Drupal\migrate\MigrateIdAuditorInterface $idAuditor */ protected $idAuditor; @@ -67,10 +67,10 @@ * The renderer service. * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager * The migration plugin manager. - * @param \Drupal\migrate\MigrateIdAuditor $id_auditor + * @param \Drupal\migrate\MigrateIdAuditorInterface $id_auditor * The ID conflict auditor. */ - public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateIdAuditor $id_auditor) { + public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrateIdAuditorInterface $id_auditor) { $this->state = $state; $this->dateFormatter = $date_formatter; $this->renderer = $renderer; only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/src/MigrateIdAuditorInterface.php @@ -0,0 +1,28 @@ +