diff --git a/core/modules/file/migration_templates/d7_file.yml b/core/modules/file/migration_templates/d7_file.yml index 8bc2147..2524d6c 100644 --- a/core/modules/file/migration_templates/d7_file.yml +++ b/core/modules/file/migration_templates/d7_file.yml @@ -1,7 +1,7 @@ # Every migration that references a file by Drupal 7 fid should specify this # migration as an optional dependency. id: d7_file -label: Files +label: Public Files migration_tags: - Drupal 7 audit_ids: true diff --git a/core/modules/file/migration_templates/d7_file_private.yml b/core/modules/file/migration_templates/d7_file_private.yml index d2e7c89..8ba650d 100644 --- a/core/modules/file/migration_templates/d7_file_private.yml +++ b/core/modules/file/migration_templates/d7_file_private.yml @@ -1,5 +1,5 @@ id: d7_file_private -label: Files +label: Private Files migration_tags: - Drupal 7 audit_ids: true diff --git a/core/modules/migrate/src/MigrateIdAuditor.php b/core/modules/migrate/src/MigrateIdAuditor.php index c350df1..dda8ba6 100644 --- a/core/modules/migrate/src/MigrateIdAuditor.php +++ b/core/modules/migrate/src/MigrateIdAuditor.php @@ -41,8 +41,8 @@ public function auditIds(array $migrations) { * @return array */ protected function buildConflict(MigrationInterface $migration) { - $conflict = []; $base_id = $migration->getBaseId(); + $conflict[$base_id] = $base_id; $label = $migration->label(); if (is_string($label)) { $conflict[$base_id] = $label; @@ -53,7 +53,6 @@ protected function buildConflict(MigrationInterface $migration) { $conflict[$base_id] = $label->getArguments()['@label']; } } - return $conflict; } diff --git a/core/modules/migrate/src/MigrateIdAuditorInterface.php b/core/modules/migrate/src/MigrateIdAuditorInterface.php index 036c884..a3ca3c0 100644 --- a/core/modules/migrate/src/MigrateIdAuditorInterface.php +++ b/core/modules/migrate/src/MigrateIdAuditorInterface.php @@ -1,6 +1,5 @@ storage->getQuery() - ->sort($field_name) + ->sort($field_name, 'DESC') ->range(0, 1); - $found = $query->execute(); - return (int) reset($found); + $highestId = reset($query->execute()); + return (int) $highestId; } } diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php index dadcdec..d02f1e1 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -44,7 +44,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP protected $eventDispatcher; /** - * The migration plugin manager to have access to the list of migrations. + * The migration plugin manager. * * @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface */ @@ -966,11 +966,11 @@ public function getHighestMigratedId($field_name) { } } - // Look in all the derived migrations' mapping tables for their highest ID. - $ids = []; + // Get the highest id from the list of map tables. + $ids = [0]; foreach ($map_tables as $map_table) { if (!$this->getDatabase()->schema()->tableExists($map_table)) { - return 0; + break; } $query = $this->getDatabase()->select($map_table, 'map') diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php index 7a1ae8f..eafb5ca 100644 --- a/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php @@ -73,7 +73,7 @@ public function testMultipleMigrationWithoutIdConflicts() { $this->getMigration('d6_node:page'), $this->getMigration('d6_node:article'), ]); - $this->assertTrue(empty($conflicts)); + $this->assertEmpty($conflicts); } /** @@ -88,7 +88,7 @@ public function testAllMigrationsWithNoIdConflicts() { // Audit the IDs of all migrations. There should be no conflicts since no // content has been created. $conflicts = $this->container->get('migrate.id_auditor')->auditIds($migrations); - $this->assertTrue(empty($conflicts)); + $this->assertEmpty($conflicts); } /** diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php index 7c20abc..e76a474 100644 --- a/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php @@ -73,7 +73,7 @@ public function testMultipleMigrationWithoutIdConflicts() { $this->getMigration('d7_node:page'), $this->getMigration('d7_node:article'), ]); - $this->assertTrue(empty($conflicts)); + $this->assertEmpty($conflicts); } /** @@ -88,7 +88,7 @@ public function testAllMigrationsWithNoIdConflicts() { // Audit the IDs of all migrations. There should be no conflicts since no // content has been created. $conflicts = $this->container->get('migrate.id_auditor')->auditIds($migrations); - $this->assertTrue(empty($conflicts)); + $this->assertEmpty($conflicts); } /** diff --git a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php index 8a29b5e..33d0d4c 100644 --- a/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -505,7 +505,7 @@ protected function conflictsForm(array &$form, FormStateInterface $form_state, $ sort($conflicts); $form['conflicts'] = [ - '#title' => $this->t('These conflicting entities are of the following types:'), + '#title' => $this->t('The conflicting entities are of the following types:'), '#theme' => 'item_list', '#items' => $conflicts, ]; @@ -535,7 +535,7 @@ protected function i18nWarningForm(array &$form, FormStateInterface $form_state, sort($i18n); $form['i18n'] = [ - '#title' => $this->t('These translatable entities are of the following types:'), + '#title' => $this->t('The translatable entities are of the following types:'), '#theme' => 'item_list', '#items' => $i18n, ]; diff --git a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php index d802653..e315ecb 100644 --- a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -131,14 +131,14 @@ protected function processStubRow(Row $row) { * {@inheritdoc} */ public function getHighestDestinationId($field_name) { - $found = parent::getHighestDestinationId($field_name); + $highestId = parent::getHighestDestinationId($field_name); // Every Drupal site must have a user with UID of 1 and it's normal for // migrations to overwrite this user. - if ($found == 1) { + if ($highestId == 1) { return 0; } - return $found; + return $highestId; } }