Skip to content
Snippets Groups Projects
Verified Commit 68c1000f authored by Dave Long's avatar Dave Long
Browse files

Issue #3052115 by huzooka, HitchShock, floydm, ranjith_kumar_k_u, Sam152,...

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
parent 0448b4bc
Branches
Tags
46 merge requests!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4594Applying patch for Views Global Text area field to allow extra HTML tags. As video, source and iframe tag is not rendering. Due to which Media embedded video and remote-video not rendering in Views Global Text area field.,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!3878Removed unused condition head title for views,!38582585169-10.1.x,!3825Issue #2972573: randomMachineName() should conform to processMachineName() pattern,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3546refactored dialog.pcss file,!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3502Issue #3335308: Confusing behavior with FormState::setFormState and FormState::setMethod,!3452Issue #3332701: Refactor Claro's tablesort-indicator stylesheet,!3451Issue #2410579: Allows setting the current language programmatically.,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3228Issue #2920678: Add config validation for the allowed characters of machine names,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3147Issue #3328457: Replace most substr($a, $i) where $i is negative with str_ends_with(),!3146Issue #3328456: Replace substr($a, 0, $i) with str_starts_with(),!3133core/modules/system/css/components/hidden.module.css,!31312878513-10.1.x,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2614Issue #2981326: Replace non-test usages of \Drupal::logger() with IoC injection,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1591Issue #3199697: Add JSON:API Translation experimental module,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!844Resolve #3036010 "Updaters",!673Issue #3214208: FinishResponseSubscriber could create duplicate headers,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
Showing
with 188 additions and 2 deletions
......@@ -3,6 +3,7 @@
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;
......@@ -215,6 +216,9 @@ public function rollback(array $destination_identifier) {
// 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,6 +233,7 @@ public function validateEntity(FieldableEntityInterface $entity) {
* An array containing the entity ID.
*/
protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
$entity->setSyncing(TRUE);
$entity->save();
return [$entity->id()];
}
......@@ -380,6 +381,7 @@ public function rollback(array $destination_identifier) {
$translation = $entity->getTranslation($langcode);
if (!$translation->isDefaultTranslation()) {
$entity->removeTranslation($langcode);
$entity->setSyncing(TRUE);
$entity->save();
}
}
......
......@@ -164,6 +164,7 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
* {@inheritdoc}
*/
protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
$entity->setSyncing(TRUE);
$entity->save();
return [$entity->getRevisionId()];
}
......
......@@ -14,6 +14,7 @@
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.
......@@ -44,6 +45,9 @@ public function testImport() {
// 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,6 +15,7 @@
use Drupal\migrate\Plugin\migrate\destination\EntityRevision as RealEntityRevision;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
/**
* Tests entity revision destination.
......@@ -178,6 +179,9 @@ public function testSave() {
$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,6 +2,7 @@
namespace Drupal\Tests\migrate_drupal_ui\Functional;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Tests\migrate_drupal\Traits\CreateTestContentEntitiesTrait;
/**
......@@ -69,4 +70,36 @@ public function useTestMailCollector() {
$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 @@ public function testUpgradeAndIncremental() {
$this->assertUserLogIn(2, 'john.doe_pass');
$this->assertFollowUpMigrationResults();
$this->assertEntityRevisionsCount('node', 26);
$this->assertEmailsSent();
}
......
<?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 @@ public function testUpgradeAndIncremental() {
$this->assertUserLogIn(2, 'a password');
$this->assertFollowUpMigrationResults();
$this->assertEntityRevisionsCount('node', 19);
$this->assertEmailsSent();
}
......
<?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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment