diff -u b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php --- b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -172,8 +172,7 @@ $plugin_id, $plugin_definition, $migration, - $container->get('event_dispatcher'), - $container->get('plugin.manager.migration') + $container->get('event_dispatcher') ); } diff -u b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php --- b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -8,7 +8,6 @@ namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination; use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\ContentEntityType; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; reverted: --- b/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php +++ a/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php @@ -3,8 +3,6 @@ namespace Drupal\Tests\migrate_drupal\Kernel; use Drupal\Core\Database\Database; -use Drupal\migrate\Audit\AuditResult; -use Drupal\migrate\Audit\IdAuditor; use Drupal\Tests\migrate\Kernel\MigrateTestBase; /** 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 @@ -494,20 +494,18 @@ $results = (new IdAuditor())->auditMultiple($migrations); /** @var \Drupal\migrate\Audit\AuditResult $result */ - foreach ($results as $migration_id => $result) { + foreach ($results as $result) { // If the migration passed the audit, we don't need to do anything. if ($result->passed()) { continue; } $destination = $result->getMigration()->getDestinationPlugin(); - $definition = $destination->getPluginDefinition(); - if ($destination instanceof EntityContentBase && $destination->isTranslationDestination()) { - $translated_content_conflicts[$migration_id] = $definition['label']; + $translated_content_conflicts[] = $result; } else { - $content_conflicts[$migration_id] = $definition['label']; + $content_conflicts[] = $result; } } if (empty($content_conflicts) && empty($translated_content_conflicts)) { @@ -523,8 +521,13 @@ $form['actions']['submit']['#submit'] = ['::submitConfirmIdConflictForm']; $form['actions']['submit']['#value'] = $this->t('I acknowledge I may lose data, continue anyway.'); - $form = $this->conflictsForm($form, $form_state, $content_conflicts); - return $this->i18nWarningForm($form, $form_state, $translated_content_conflicts); + if ($content_conflicts) { + $form = $this->conflictsForm($form, $form_state, $content_conflicts); + } + if ($translated_content_conflicts) { + $form = $this->i18nWarningForm($form, $form_state, $translated_content_conflicts); + } + return $form; } /** @@ -534,54 +537,70 @@ * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. - * @param array $content_conflicts - * The conflicted migration labels. + * @param \Drupal\migrate\Audit\AuditResult[] $conflicts + * The failing audit results. * * @return array * The form structure. */ - protected function conflictsForm(array &$form, FormStateInterface $form_state, $content_conflicts) { - if (empty($content_conflicts)) { - return $form; - } - + protected function conflictsForm(array &$form, FormStateInterface $form_state, array $conflicts) { $form['warning']['#markup'] .= '
' . $this->t('Upgrades work on clean and empty new installs of Drupal 8. However, it looks like you have content in your site that is unknown to the migrate system; perhaps manually added. These new entities may be overwritten if you run this upgrade. For more information, see the online handbook entry for handling migration conflicts.', [':id-conflicts-handbook' => 'https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#id_conflicts']) . '
'; - sort($content_conflicts); $form['conflicts'] = [ '#title' => $this->t('The conflicting content are of the following types:'), '#theme' => 'item_list', - '#items' => $content_conflicts, + '#items' => $this->formatConflicts($conflicts), ]; return $form; } /** + * Formats a set of failing audit results as strings. + * + * Each string is the label of the destination plugin of the migration that + * failed the audit, keyed by the destination plugin ID in order to prevent + * duplication. + * + * @param \Drupal\migrate\Audit\AuditResult[] $conflicts + * The failing audit results. + * + * @return string[] + * The formatted audit results. + */ + protected function formatConflicts(array $conflicts) { + $items = []; + + foreach ($conflicts as $conflict) { + $definition = $conflict->getMigration()->getDestinationPlugin()->getPluginDefinition(); + $id = $definition['id']; + $items[$id] = $definition['label']; + } + sort($items); + + return $items; + } + + /** * Build the markup for i18n warnings. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. - * @param array $translated_content_conflicts - * The conflicted translated migration labels. + * @param \Drupal\migrate\Audit\AuditResult[] $conflicts + * The failing audit results. * * @return array * The form structure. */ - protected function i18nWarningForm(array &$form, FormStateInterface $form_state, $translated_content_conflicts) { - if (empty($translated_content_conflicts)) { - return $form; - } - + protected function i18nWarningForm(array &$form, FormStateInterface $form_state, array $conflicts) { $form['warning']['#markup'] .= '' . $this->t('It looks like you are migrating translated content. Be extra cautious and make sure you aren\'t introducting any conflicts. For more on the subject, see the online handbook entry for handling migration conflicts.', [':id-conflicts-handbook' => 'https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#id_conflicts']) . '
'; - sort($translated_content_conflicts); $form['i18n'] = [ '#title' => $this->t('The translated content are of the following types:'), '#theme' => 'item_list', - '#items' => $translated_content_conflicts, + '#items' => $this->formatConflicts($conflicts), ]; return $form;