diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php index ca59448940..a827781b4f 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationRevisionRevertTest.php @@ -146,8 +146,8 @@ public function testRevertingToState() { $this->drupalGet($revision_url); $this->assertSession()->fieldExists('revert_state'); - $this->assertSession()->optionExists('revert_state', 'draft'); - $this->assertSession()->optionNotExists('revert_state', 'published'); + $this->assertSession()->optionExists('revert_state', 'published'); + $this->assertSession()->optionNotExists('revert_state', 'draft'); // Now revert and set to a published state. $this->drupalPostForm(NULL, ['revert_state' => 'published'], t('Revert')); @@ -175,6 +175,7 @@ public function testRevertingToState() { $this->clickLink(t('Set as current revision')); $this->drupalPostForm(NULL, ['revert_state' => 'published'], t('Revert')); + $node_storage->resetCache(); $revision = $node_storage->loadRevision($node_storage->getLatestRevisionId($node->id())); $this->assertTrue($revision->isPublished()); } diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php index b2abed2b01..eb486f076c 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationPermissionsTest.php @@ -63,6 +63,14 @@ public function permissionsTestCases() { 'use simple_workflow transition create_new_draft' => [ 'title' => 'Simple Workflow workflow: Use Create New Draft transition.', ], + 'revert simple_workflow revisions to draft' => [ + 'title' => 'Simple Workflow workflow: Revert revisions to Draft state', + 'description' => 'For supported entity types assigned to the Simple Workflow workflow, allows users to revert any content revision to the Draft state. Reverting revisions will not consider any existing transition based permissions.' + ], + 'revert simple_workflow revisions to published' => [ + 'title' => 'Simple Workflow workflow: Revert revisions to Published state', + 'description' => 'For supported entity types assigned to the Simple Workflow workflow, allows users to revert any content revision to the Published state. Reverting revisions will not consider any existing transition based permissions.', + ], ], ], 'Non Content Moderation Workflow' => [ diff --git a/core/modules/node/src/Form/NodeRevisionRevertForm.php b/core/modules/node/src/Form/NodeRevisionRevertForm.php index da5cba023c..4e4345ed01 100644 --- a/core/modules/node/src/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/src/Form/NodeRevisionRevertForm.php @@ -112,7 +112,7 @@ public function getDescription() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL) { - $this->revision = $this->nodeStorage->loadRevision($node_revision); + $this->revision = $this->nodeStorage->createRevision($this->nodeStorage->loadRevision($node_revision)); $form = parent::buildForm($form, $form_state); return $form;