summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2016-10-11 19:51:35 (GMT)
committerwebchick2016-10-11 19:51:35 (GMT)
commit8dc87c91c364c0228dc9190162c7e74e8cd2dbc0 (patch)
tree326d7a4437581918024afe9dda169e9a5ec030bb
parent4f917488f11cee91a31e6660b7738ee7e37d7064 (diff)
Issue #2744877 by katzilla, dernetzjaeger, biancajs, chipway, Gábor Hojtsy, catch, romainj, lucur, yoroy, kamalrajsahu21, dietmarg: Node add form shows 'create new revision' checkbox
-rw-r--r--core/modules/node/src/NodeForm.php2
-rw-r--r--core/modules/node/src/Tests/NodeCreationTest.php6
-rw-r--r--core/modules/node/src/Tests/NodeEditFormTest.php4
3 files changed, 11 insertions, 1 deletions
diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php
index 82faab7..d9437db 100644
--- a/core/modules/node/src/NodeForm.php
+++ b/core/modules/node/src/NodeForm.php
@@ -139,7 +139,7 @@ class NodeForm extends ContentEntityForm {
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $node->type->entity->isNewRevision(),
- '#access' => $current_user->hasPermission('administer nodes'),
+ '#access' => $current_user->hasPermission('administer nodes') && !$node->isNew(),
'#group' => 'revision_information',
);
diff --git a/core/modules/node/src/Tests/NodeCreationTest.php b/core/modules/node/src/Tests/NodeCreationTest.php
index bf3ce86..7c4e142 100644
--- a/core/modules/node/src/Tests/NodeCreationTest.php
+++ b/core/modules/node/src/Tests/NodeCreationTest.php
@@ -72,6 +72,12 @@ class NodeCreationTest extends NodeTestBase {
$this->drupalGet('node/' . $node->id());
$this->assertText($node->getOwner()->getUsername());
$this->assertText(format_date($node->getCreatedTime()));
+
+ // Check if the node revision checkbox is not rendered on node creation form.
+ $admin_user = $this->drupalCreateUser(array('administer nodes', 'create page content'));
+ $this->drupalLogin($admin_user);
+ $this->drupalGet('node/add/page');
+ $this->assertNoFieldById('edit-revision', NULL , 'The revision checkbox is not present.');
}
/**
diff --git a/core/modules/node/src/Tests/NodeEditFormTest.php b/core/modules/node/src/Tests/NodeEditFormTest.php
index b154ca0..0d6bf45 100644
--- a/core/modules/node/src/Tests/NodeEditFormTest.php
+++ b/core/modules/node/src/Tests/NodeEditFormTest.php
@@ -111,6 +111,10 @@ class NodeEditFormTest extends NodeTestBase {
$first_node_version = node_revision_load($node->getRevisionId());
$second_node_version = node_revision_load($revised_node->getRevisionId());
$this->assertNotIdentical($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');
+
+ // Check if the node revision checkbox is rendered on node edit form.
+ $this->drupalGet('node/' . $node->id() . '/edit');
+ $this->assertFieldById('edit-revision', NULL, 'The revision field is present.');
}
/**