summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNathaniel Catchpole2019-01-18 11:08:06 (GMT)
committerNathaniel Catchpole2019-01-18 11:08:06 (GMT)
commitf49330eaae74f965f819f2943905094bd3035ec5 (patch)
tree009ed69efe84823a57b6a79579f876f534ddd099 /core
parent1ad9e2690587c8d947408163340a86e48599652b (diff)
Revert "Issue #3003238 by Sam152, amateescu, Berdir: EntityStorageException: Default revision can not be deleted in content_moderation_entity_revision_delete()"
This reverts commit de323cd29b24d9b865fb7173e6a5e68f9275430f.
Diffstat (limited to 'core')
-rw-r--r--core/modules/content_moderation/src/EntityOperations.php9
-rw-r--r--core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php24
2 files changed, 4 insertions, 29 deletions
diff --git a/core/modules/content_moderation/src/EntityOperations.php b/core/modules/content_moderation/src/EntityOperations.php
index 52d2ca3..8c6d332 100644
--- a/core/modules/content_moderation/src/EntityOperations.php
+++ b/core/modules/content_moderation/src/EntityOperations.php
@@ -235,11 +235,10 @@ class EntityOperations implements ContainerInjectionInterface {
* @see hook_entity_revision_delete()
*/
public function entityRevisionDelete(EntityInterface $entity) {
- if ($content_moderation_state = ContentModerationStateEntity::loadFromModeratedEntity($entity)) {
- if ($content_moderation_state->isDefaultRevision()) {
- $content_moderation_state->delete();
- }
- else {
+ /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
+ if (!$entity->isDefaultRevision()) {
+ $content_moderation_state = ContentModerationStateEntity::loadFromModeratedEntity($entity);
+ if ($content_moderation_state) {
$this->entityTypeManager
->getStorage('content_moderation_state')
->deleteRevision($content_moderation_state->getRevisionId());
diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
index a1c3832..4b7d75b 100644
--- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
+++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
@@ -239,30 +239,6 @@ class ContentModerationStateTest extends KernelTestBase {
}
/**
- * Tests removal of content moderation state entities for preexisting content.
- */
- public function testExistingContentModerationStateDataRemoval() {
- $storage = $this->entityTypeManager->getStorage('entity_test_mulrevpub');
-
- $entity = $storage->create([]);
- $entity->save();
- $original_revision_id = $entity->getRevisionId();
-
- $workflow = $this->createEditorialWorkflow();
- $workflow->getTypePlugin()->addEntityTypeAndBundle($entity->getEntityTypeId(), $entity->bundle());
- $workflow->save();
-
- $entity->moderation_state = 'draft';
- $entity->save();
-
- $storage->deleteRevision($entity->getRevisionId());
-
- $entity = $this->reloadEntity($entity);
- $this->assertEquals('published', $entity->moderation_state->value);
- $this->assertEquals($original_revision_id, $storage->getLatestRevisionId($entity->id()));
- }
-
- /**
* Tests removal of content moderation state translations.
*
* @dataProvider basicModerationTestCases