From 412f414dc7daaadb1e95bb7978e2306803e2550f Mon Sep 17 00:00:00 2001 From: Dave Long Date: Thu, 15 Jun 2023 18:22:59 +0100 Subject: [PATCH] Revert "Issue #3052115 by huzooka, HitchShock, floydm, ranjith_kumar_k_u, Sam152, edysmp, codebymikey, herved, Wim Leers, quietone, hchonov, Berdir, DamienMcKenna, rclemings, donquixote, benjifisher, fengtan, jwilson3: Mark an entity as 'syncing' during a migration update" This reverts commit 68c1000f77094b6b20d5f693f11ad1e0313538e9. --- .../src/Plugin/migrate/destination/Entity.php | 4 - .../migrate/destination/EntityContentBase.php | 2 - .../migrate/destination/EntityRevision.php | 1 - .../destination/EntityContentBaseTest.php | 4 - .../Unit/destination/EntityRevisionTest.php | 4 - .../MigrateUpgradeExecuteTestBase.php | 33 --------- .../tests/src/Functional/d6/Upgrade6Test.php | 2 +- .../d6/Upgrade6TestWithContentModeration.php | 73 ------------------- .../tests/src/Functional/d7/Upgrade7Test.php | 2 +- .../d7/Upgrade7TestWithContentModeration.php | 65 ----------------- 10 files changed, 2 insertions(+), 188 deletions(-) delete mode 100644 core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6TestWithContentModeration.php delete mode 100644 core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7TestWithContentModeration.php diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index b7faaae4910..3a2f93be4da 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -3,7 +3,6 @@ namespace Drupal\migrate\Plugin\migrate\destination; use Drupal\Component\Plugin\DependentPluginInterface; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\DependencyTrait; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; @@ -216,9 +215,6 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI // Delete the specified entity from Drupal if it exists. $entity = $this->storage->load(reset($destination_identifier)); if ($entity) { - if ($entity instanceof ContentEntityInterface) { - $entity->setSyncing(TRUE); - } $entity->delete(); } } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php index cd1c24c2916..2b439cd2cb3 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -233,7 +233,6 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal * An array containing the entity ID. */ protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) { - $entity->setSyncing(TRUE); $entity->save(); return [$entity->id()]; } @@ -381,7 +380,6 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal $translation = $entity->getTranslation($langcode); if (!$translation->isDefaultTranslation()) { $entity->removeTranslation($langcode); - $entity->setSyncing(TRUE); $entity->save(); } } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php index 16d986999ce..b387815724b 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php @@ -164,7 +164,6 @@ class EntityRevision extends EntityContentBase { * {@inheritdoc} */ protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) { - $entity->setSyncing(TRUE); $entity->save(); return [$entity->getRevisionId()]; } diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php index 0f1f38f1019..3319b71a19d 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -14,7 +14,6 @@ use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\migrate\Row; -use Prophecy\Argument; /** * Tests base entity migration destination functionality. @@ -45,9 +44,6 @@ class EntityContentBaseTest extends EntityTestBase { // Assert that save is called. $entity->save() ->shouldBeCalledTimes(1); - // Syncing should be set once. - $entity->setSyncing(Argument::exact(TRUE)) - ->shouldBeCalledTimes(1); // Set an id for the entity $entity->id() ->willReturn(5); diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php index 096f9a231ae..374db8a9461 100644 --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -15,7 +15,6 @@ use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityRevision as RealEntityRevision; use Drupal\migrate\Row; use Drupal\Tests\UnitTestCase; -use Prophecy\Argument; /** * Tests entity revision destination. @@ -179,9 +178,6 @@ class EntityRevisionTest extends UnitTestCase { $entity = $this->prophesize('\Drupal\Core\Entity\ContentEntityInterface'); $entity->save() ->shouldBeCalled(); - // Syncing should be set once. - $entity->setSyncing(Argument::exact(TRUE)) - ->shouldBeCalledTimes(1); $entity->getRevisionId() ->shouldBeCalled() ->willReturn(1234); diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php index 10288106c3f..f28f6b4dc4a 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeExecuteTestBase.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\migrate_drupal_ui\Functional; -use Drupal\Core\Entity\ContentEntityStorageInterface; use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait; /** @@ -70,36 +69,4 @@ abstract class MigrateUpgradeExecuteTestBase extends MigrateUpgradeTestBase { $this->writeSettings($settings); } - /** - * Checks the number of the specified entity's revisions. - * - * Revision translations are excluded. - * - * @param string $content_entity_type_id - * The entity type ID of the content entity, e.g. 'node', 'media', - * 'block_content'. - * @param int $expected_revision_count - * The expected number of the revisions. - * - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException - */ - protected function assertEntityRevisionsCount(string $content_entity_type_id, int $expected_revision_count) { - $entity_storage = \Drupal::entityTypeManager()->getStorage($content_entity_type_id); - assert($entity_storage instanceof ContentEntityStorageInterface); - $revision_ids = $entity_storage - ->getQuery() - ->allRevisions() - ->accessCheck(FALSE) - ->execute(); - $this->assertCount( - $expected_revision_count, - $revision_ids, - sprintf( - "The number of %s revisions is different than expected", - $content_entity_type_id - ) - ); - } - } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php index c7eed2b2d90..1e6249c2e27 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php @@ -200,7 +200,7 @@ class Upgrade6Test extends MigrateUpgradeExecuteTestBase { $this->assertUserLogIn(2, 'john.doe_pass'); $this->assertFollowUpMigrationResults(); - $this->assertEntityRevisionsCount('node', 26); + $this->assertEmailsSent(); } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6TestWithContentModeration.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6TestWithContentModeration.php deleted file mode 100644 index 4a46e7f3631..00000000000 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6TestWithContentModeration.php +++ /dev/null @@ -1,73 +0,0 @@ -drupalCreateContentType(['type' => $type]); - } - $editorial = Workflow::load('editorial'); - assert($editorial instanceof WorkflowInterface); - $type_settings = $editorial->getTypePlugin()->getConfiguration(); - $type_settings['default_moderation_state'] = 'published'; - $type_settings['entity_types']['node'] = array_merge( - ['page', 'forum'], - $types - ); - $type_plugin = $editorial->getTypePlugin(); - $type_plugin->setConfiguration($type_settings); - $editorial->trustData()->save(); - } - - /** - * {@inheritdoc} - */ - protected function getEntityCounts() { - $entity_counts = parent::getEntityCounts() + [ - 'content_moderation_state' => 18, - 'workflow' => 1, - ]; - $entity_counts['field_config'] = $entity_counts['field_config'] + 1; - $entity_counts['view'] = $entity_counts['view'] + 1; - return $entity_counts; - } - - /** - * {@inheritdoc} - */ - protected function getEntityCountsIncremental() { - $entity_counts_incremental = parent::getEntityCountsIncremental(); - $entity_counts_incremental['content_moderation_state'] = $entity_counts_incremental['content_moderation_state'] + 1; - return $entity_counts_incremental; - } - -} diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php index 960fffae0a4..05baccd7985 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php @@ -227,7 +227,7 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase { $this->assertUserLogIn(2, 'a password'); $this->assertFollowUpMigrationResults(); - $this->assertEntityRevisionsCount('node', 19); + $this->assertEmailsSent(); } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7TestWithContentModeration.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7TestWithContentModeration.php deleted file mode 100644 index 5d4ec2dc6d9..00000000000 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7TestWithContentModeration.php +++ /dev/null @@ -1,65 +0,0 @@ -drupalCreateContentType(['type' => $type]); - } - - $editorial = Workflow::load('editorial'); - assert($editorial instanceof WorkflowInterface); - $type_settings = $editorial->getTypePlugin()->getConfiguration(); - $type_settings['default_moderation_state'] = 'published'; - $type_settings['entity_types']['node'] = array_merge( - ['article', 'forum'], - $types - ); - $type_plugin = $editorial->getTypePlugin(); - $type_plugin->setConfiguration($type_settings); - $editorial->trustData()->save(); - } - - /** - * {@inheritdoc} - */ - protected function getEntityCounts() { - $entity_counts = parent::getEntityCounts() + [ - 'content_moderation_state' => 7, - 'workflow' => 1, - ]; - $entity_counts['entity_view_display'] = $entity_counts['entity_view_display'] + 1; - $entity_counts['field_config'] = $entity_counts['field_config'] + 2; - $entity_counts['view'] = $entity_counts['view'] + 1; - return $entity_counts; - } - -}