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 68c1000f77
.
merge-requests/3933/head
parent
a87a72fa06
commit
412f414dc7
core/modules
migrate
src/Plugin/migrate/destination
tests/src/Unit
Plugin/migrate/destination
destination
migrate_drupal_ui/tests/src/Functional
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
|
|||
$this->assertUserLogIn(2, 'john.doe_pass');
|
||||
|
||||
$this->assertFollowUpMigrationResults();
|
||||
$this->assertEntityRevisionsCount('node', 26);
|
||||
|
||||
$this->assertEmailsSent();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal_ui\Functional\d6;
|
||||
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\workflows\WorkflowInterface;
|
||||
|
||||
/**
|
||||
* Tests Drupal 6 upgrade using the migrate UI with Content Moderation.
|
||||
*
|
||||
* @group migrate_drupal_ui
|
||||
*/
|
||||
class Upgrade6TestWithContentModeration extends Upgrade6Test {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'content_moderation',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
// Set up a moderation flow.
|
||||
$types = [
|
||||
'story',
|
||||
'test_planet',
|
||||
'company',
|
||||
'employee',
|
||||
];
|
||||
foreach ($types as $type) {
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -227,7 +227,7 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
|
|||
$this->assertUserLogIn(2, 'a password');
|
||||
|
||||
$this->assertFollowUpMigrationResults();
|
||||
$this->assertEntityRevisionsCount('node', 19);
|
||||
|
||||
$this->assertEmailsSent();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal_ui\Functional\d7;
|
||||
|
||||
use Drupal\workflows\Entity\Workflow;
|
||||
use Drupal\workflows\WorkflowInterface;
|
||||
|
||||
/**
|
||||
* Tests Drupal 7 upgrade using the migrate UI with Content Moderation.
|
||||
*
|
||||
* @group migrate_drupal_ui
|
||||
*/
|
||||
class Upgrade7TestWithContentModeration extends Upgrade7Test {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'content_moderation',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
// Set up a moderation flow.
|
||||
$types = [
|
||||
'blog',
|
||||
'et',
|
||||
'test_content_type',
|
||||
];
|
||||
foreach ($types as $type) {
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue