From 6f4affd1e667a73b6b8df723466d6e793ec5ca25 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 8 Mar 2018 22:10:50 +0000
Subject: [PATCH] Issue #2865223 by timmillwood, amateescu: Node type form
 alter sets new revision to false on subsequent saves

---
 .../src/Entity/Handler/NodeModerationHandler.php              | 2 +-
 .../tests/src/Functional/ModerationStateTestBase.php          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php b/core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php
index 7e9aca3eb05f..87e1b22c8d9c 100644
--- a/core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php
+++ b/core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php
@@ -54,7 +54,7 @@ public function enforceRevisionsEntityFormAlter(array &$form, FormStateInterface
    */
   public function enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id) {
     // Force the revision checkbox on.
-    $form['workflow']['options']['#default_value']['revision'] = 'revision';
+    $form['workflow']['options']['#value']['revision'] = 'revision';
     $form['workflow']['options']['revision']['#disabled'] = TRUE;
   }
 
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php
index 712732f9f619..ad77b4337205 100644
--- a/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php
+++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php
@@ -3,6 +3,7 @@
 namespace Drupal\Tests\content_moderation\Functional;
 
 use Drupal\Core\Session\AccountInterface;
+use Drupal\node\Entity\NodeType;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\user\Entity\Role;
 
@@ -110,6 +111,9 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save content type'));
 
+    // Check the content type has been set to create new revisions.
+    $this->assertTrue(NodeType::load($content_type_id)->isNewRevision());
+
     if ($moderated) {
       $this->enableModerationThroughUi($content_type_id, $workflow_id);
     }
-- 
GitLab