diff --git a/core/modules/book/config/install/core.entity_form_display.node.book.default.yml b/core/modules/book/config/install/core.entity_form_display.node.book.default.yml index 1ec4eb1..ef673ca 100644 --- a/core/modules/book/config/install/core.entity_form_display.node.book.default.yml +++ b/core/modules/book/config/install/core.entity_form_display.node.book.default.yml @@ -30,6 +30,12 @@ content: display_label: true weight: 15 third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 120 + third_party_settings: { } sticky: type: boolean_checkbox settings: diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php index cc19a98..7c640be 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceXSSTest.php @@ -64,9 +64,10 @@ public function testEntityReferenceXSS() { $edit = [ 'title[0][value]' => $this->randomString(), - 'entity_reference_test' => $referenced_node->id() + 'entity_reference_test' => $referenced_node->id(), + 'status[value]' => TRUE, ]; - $this->drupalPostForm(NULL, $edit, 'Save and publish'); + $this->drupalPostForm(NULL, $edit, 'Save'); $this->assertEscaped($referenced_node->getTitle()); // Test the options_buttons type. diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php index aa4923c..a6c9c1a 100644 --- a/core/modules/file/src/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php @@ -73,8 +73,11 @@ function testNodeDisplay() { $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); // Turn the "display" option off and check that the file is no longer displayed. - $edit = array($field_name . '[0][display]' => FALSE); - $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published')); + $edit = array( + $field_name . '[0][display]' => FALSE, + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.'); @@ -83,8 +86,9 @@ function testNodeDisplay() { $edit = array( $field_name . '[0][description]' => $description, $field_name . '[0][display]' => TRUE, + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $this->assertText($description); // Ensure the filename in the link's title attribute is escaped. @@ -163,8 +167,9 @@ function testDescToggle() { $edit = array( 'title[0][value]' => $title, 'files[field_' . $field_name . '_0]' => drupal_realpath($file->uri), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); + $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertText(t('The description may be used as the label of the link to the file.')); diff --git a/core/modules/file/src/Tests/FileFieldRevisionTest.php b/core/modules/file/src/Tests/FileFieldRevisionTest.php index 7da2a90..d3ba1ca 100644 --- a/core/modules/file/src/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/src/Tests/FileFieldRevisionTest.php @@ -68,7 +68,11 @@ function testRevisions() { // Save a new version of the node without any changes. // Check that the file is still the same as the previous revision. - $this->drupalPostForm('node/' . $nid . '/edit', array('revision' => '1'), t('Save and keep published')); + $edit = array( + 'revision' => TRUE, + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $node_storage->resetCache(array($nid)); $node = $node_storage->load($nid); $node_file_r3 = File::load($node->{$field_name}->target_id); diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index 5874cf5..54541bd 100644 --- a/core/modules/file/src/Tests/FileFieldTestBase.php +++ b/core/modules/file/src/Tests/FileFieldTestBase.php @@ -189,6 +189,7 @@ function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision $edit = array( 'title[0][value]' => $this->randomMachineName(), 'revision' => (string) (int) $new_revision, + 'status[value]' => TRUE, ); $node_storage = $this->container->get('entity.manager')->getStorage('node'); @@ -227,7 +228,7 @@ function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision $edit[$name][] = $file_path; } } - $this->drupalPostForm("node/$nid/edit", $edit, t('Save and keep published')); + $this->drupalPostForm("node/$nid/edit", $edit, t('Save')); return $nid; } @@ -240,10 +241,11 @@ function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_revision function removeNodeFile($nid, $new_revision = TRUE) { $edit = array( 'revision' => (string) (int) $new_revision, + 'status[value]' => TRUE, ); $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove')); - $this->drupalPostForm(NULL, $edit, t('Save and keep published')); + $this->drupalPostForm(NULL, $edit, t('Save')); } /** @@ -253,10 +255,11 @@ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { $edit = array( 'files[' . $field_name . '_0]' => drupal_realpath($file->getFileUri()), 'revision' => (string) (int) $new_revision, + 'status[value]' => TRUE, ); $this->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove')); - $this->drupalPostForm(NULL, $edit, t('Save and keep published')); + $this->drupalPostForm(NULL, $edit, t('Save')); } /** diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php index 12fe925..53c4904 100644 --- a/core/modules/file/src/Tests/FileFieldValidateTest.php +++ b/core/modules/file/src/Tests/FileFieldValidateTest.php @@ -32,9 +32,11 @@ function testRequired() { $test_file = $this->getTestFile('text'); // Try to post a new node without uploading a file. - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(); - $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required file field was empty.'); // Create a new node with the uploaded file. @@ -53,9 +55,11 @@ function testRequired() { $this->createFileField($field_name, 'node', $type_name, array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), array('required' => '1')); // Try to post a new node without uploading a file in the multivalue field. - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(); - $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('@title field is required.', array('@title' => $field->getLabel())), 'Node save failed when required multiple value file field was empty.'); // Create a new node with the uploaded file into the multivalue field. diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 7b0cce5..f791481 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -93,7 +93,10 @@ function testSingleValuedWidget() { $this->assertTrue(isset($label[0]), 'Label for upload found.'); // Save the node and ensure it does not have the file. - $this->drupalPostForm(NULL, array(), t('Save and keep published')); + $edit = array( + 'status[value]' => TRUE, + ); + $this->drupalPostForm(NULL, $edit, t('Save')); $node_storage->resetCache(array($nid)); $node = $node_storage->load($nid); $this->assertTrue(empty($node->{$field_name}->target_id), 'File was successfully removed from the node.'); @@ -210,7 +213,11 @@ function testMultiValuedWidget() { $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); // Save the node and ensure it does not have any files. - $this->drupalPostForm(NULL, array('title[0][value]' => $this->randomMachineName()), t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm(NULL, $edit, t('Save')); $matches = array(); preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; @@ -332,8 +339,9 @@ function testPrivateFileComment() { // Create node. $edit = array( 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); + $this->drupalPostForm('node/add/article', $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); // Add a comment with a file. @@ -367,7 +375,10 @@ function testPrivateFileComment() { // Unpublishes node. $this->drupalLogin($this->adminUser); - $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish')); + $edit = array( + 'status[value]' => FALSE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Ensures normal user can no longer download the file. $this->drupalLogin($user); diff --git a/core/modules/file/src/Tests/FilePrivateTest.php b/core/modules/file/src/Tests/FilePrivateTest.php index a11c81a..7e5280c 100644 --- a/core/modules/file/src/Tests/FilePrivateTest.php +++ b/core/modules/file/src/Tests/FilePrivateTest.php @@ -75,12 +75,16 @@ function testPrivateFile() { $this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.'); // Attempt to reuse the file when editing a node. - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(); - $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $edit[$field_name . '[0][fids]'] = $node_file->id(); - $this->drupalPostForm('node/' . $new_node->id() .'/edit', $edit, t('Save and keep published')); + $edit = array( + $field_name . '[0][fids]' => $node_file->id(), + ); + $this->drupalPostForm('node/' . $new_node->id() .'/edit', $edit, t('Save')); // Make sure the form submit failed - we stayed on the edit form. $this->assertUrl('node/' . $new_node->id() .'/edit'); // Check that we got the expected constraint form error. @@ -88,10 +92,12 @@ function testPrivateFile() { $this->assertRaw(SafeMarkup::format($constraint->message, array('%type' => 'file', '%id' => $node_file->id()))); // Attempt to reuse the existing file when creating a new node, and confirm // that access is still denied. - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(); - $edit[$field_name . '[0][fids]'] = $node_file->id(); - $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + $field_name . '[0][fids]' => $node_file->id(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save')); $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertTrue(empty($new_node), 'Node was not created.'); $this->assertUrl('node/add/' . $type_name); diff --git a/core/modules/filter/src/Tests/FilterHooksTest.php b/core/modules/filter/src/Tests/FilterHooksTest.php index b068354..af910ca 100644 --- a/core/modules/filter/src/Tests/FilterHooksTest.php +++ b/core/modules/filter/src/Tests/FilterHooksTest.php @@ -61,11 +61,13 @@ function testFilterHooks() { // Use the format created. $title = $this->randomMachineName(8); - $edit = array(); - $edit['title[0][value]'] = $title; - $edit['body[0][value]'] = $this->randomMachineName(32); - $edit['body[0][format]'] = $format_id; - $this->drupalPostForm("node/add/{$type->id()}", $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $title, + 'body[0][value]' => $this->randomMachineName(32), + 'body[0][format]' => $format_id, + 'status[value]' => TRUE, + ); + $this->drupalPostForm("node/add/{$type->id()}", $edit, t('Save')); $this->assertText(t('@type @title has been created.', array('@type' => $type_name, '@title' => $title))); // Disable the text format. diff --git a/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml b/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml index c66ba23..d1db354 100644 --- a/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml +++ b/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml @@ -38,6 +38,12 @@ content: display_label: true weight: 15 third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 100 + third_party_settings: { } sticky: type: boolean_checkbox settings: diff --git a/core/modules/forum/src/Tests/ForumBlockTest.php b/core/modules/forum/src/Tests/ForumBlockTest.php index f505bdf..9283b28 100644 --- a/core/modules/forum/src/Tests/ForumBlockTest.php +++ b/core/modules/forum/src/Tests/ForumBlockTest.php @@ -171,10 +171,11 @@ protected function createForumTopics($count = 5) { // adding the index. 'created[0][value][date]' => $date->format('Y-m-d'), 'created[0][value][time]' => $date->format('H:i:s'), + 'status[value]' => TRUE, ); // Create the forum topic, preselecting the forum ID via a URL parameter. - $this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), array('query' => array('forum_id' => 1))); + $this->drupalPostForm('node/add/forum', $edit, t('Save'), array('query' => array('forum_id' => 1))); $topics[] = $title; } diff --git a/core/modules/forum/src/Tests/ForumIndexTest.php b/core/modules/forum/src/Tests/ForumIndexTest.php index e84a3eb..4fae847 100644 --- a/core/modules/forum/src/Tests/ForumIndexTest.php +++ b/core/modules/forum/src/Tests/ForumIndexTest.php @@ -43,13 +43,14 @@ function testForumIndexStatus() { $edit = array( 'title[0][value]' => $title, 'body[0][value]' => $this->randomMachineName(200), + 'status[value]' => TRUE, ); // Create the forum topic, preselecting the forum ID via a URL parameter. $this->drupalGet("forum/$tid"); $this->clickLink(t('Add new @node_type', array('@node_type' => 'Forum topic'))); $this->assertUrl('node/add/forum', array('query' => array('forum_id' => $tid))); - $this->drupalPostForm(NULL, $edit, t('Save and publish')); + $this->drupalPostForm(NULL, $edit, t('Save')); // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($title); @@ -76,7 +77,10 @@ function testForumIndexStatus() { // Unpublish the node. - $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish')); + $edit = array( + 'status[value]' => FALSE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->id()); $this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.'); diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index 53ba09f..b07a62c 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -271,8 +271,9 @@ function testImageFieldSettings() { $edit = array( $field_name . '[0][alt]' => $image['#alt'], $field_name . '[0][title]' => $image['#title'], + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $default_output = str_replace("\n", NULL, $renderer->renderRoot($image)); $this->assertRaw($default_output, 'Image displayed using user supplied alt and title attributes.'); @@ -281,8 +282,9 @@ function testImageFieldSettings() { $edit = array( $field_name . '[0][alt]' => $this->randomMachineName($test_size), $field_name . '[0][title]' => $this->randomMachineName($test_size), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save')); $schema = $field->getFieldStorageDefinition()->getSchema(); $this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', array( '%max' => $schema['columns']['alt']['length'], @@ -303,10 +305,11 @@ function testImageFieldSettings() { $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings')); $edit = array( 'files[' . $field_name . '_1][]' => drupal_realpath($test_image->uri), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Add the required alt text. - $this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save and keep published')); + $this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save')); $this->assertText(format_string('Article @title has been updated.', array('@title' => $node->getTitle()))); // Assert ImageWidget::process() calls FieldWidget::process(). diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php index 271b969..f73fd5c 100644 --- a/core/modules/image/src/Tests/ImageFieldTestBase.php +++ b/core/modules/image/src/Tests/ImageFieldTestBase.php @@ -135,12 +135,13 @@ function previewNodeImage($image, $field_name, $type) { function uploadNodeImage($image, $field_name, $type, $alt = '') { $edit = array( 'title[0][value]' => $this->randomMachineName(), + 'files[' . $field_name . '_0]' => drupal_realpath($image->uri), + 'status[value]' => TRUE, ); - $edit['files[' . $field_name . '_0]'] = drupal_realpath($image->uri); - $this->drupalPostForm('node/add/' . $type, $edit, t('Save and publish')); + $this->drupalPostForm('node/add/' . $type, $edit, t('Save')); if ($alt) { // Add alt text. - $this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save and publish')); + $this->drupalPostForm(NULL, [$field_name . '[0][alt]' => $alt], t('Save')); } // Retrieve ID of the newly created node from the current URL. diff --git a/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/src/Tests/ImageFieldValidateTest.php index c5ea831..014c05f 100644 --- a/core/modules/image/src/Tests/ImageFieldValidateTest.php +++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php @@ -87,8 +87,9 @@ function testRequiredAttributes() { $edit = array( 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); + $this->drupalPostForm('node/add/article', $edit, t('Save')); $this->assertNoText(t('Alternative text field is required.')); $this->assertNoText(t('Title field is required.')); @@ -100,8 +101,9 @@ function testRequiredAttributes() { $edit = array( 'title[0][value]' => $this->randomMachineName(), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); + $this->drupalPostForm('node/add/article', $edit, t('Save')); $this->assertNoText(t('Alternative text field is required.')); $this->assertNoText(t('Title field is required.')); diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 7c01f6f..e76199c 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -334,11 +334,7 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { '#description' => t('Menu links with lower weights are displayed before links with higher weights.'), ); - foreach (array_keys($form['actions']) as $action) { - if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') { - $form['actions'][$action]['#submit'][] = 'menu_ui_form_node_form_submit'; - } - } + $form['actions']['submit']['#submit'][] = 'menu_ui_form_node_form_submit'; } /** diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php index b3397cc..6e8156c 100644 --- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php +++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php @@ -18,13 +18,6 @@ class MenuNodeTest extends WebTestBase { /** - * An editor user. - * - * @var \Drupal\user\UserInterface - */ - protected $editor; - - /** * Modules to enable. * * @var array @@ -39,15 +32,14 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->editor = $this->drupalCreateUser(array( + $this->drupalLogin($this->drupalCreateUser(array( 'access administration pages', 'administer content types', 'administer menu', 'create page content', 'edit any page content', 'delete any page content', - )); - $this->drupalLogin($this->editor); + ))); } /** @@ -128,36 +120,6 @@ function testMenuNodeFormWidget() { $this->drupalGet('test-page'); $this->assertNoLink($node_title); - // Use not only the save button, but also the two special buttons: - // 'Save and publish' as well as 'Save and keep published'. - // These buttons just appear for 'administer nodes' users. - $admin_user = $this->drupalCreateUser([ - 'access administration pages', - 'administer content types', - 'administer nodes', - 'administer menu', - 'create page content', - 'edit any page content', - ]); - $this->drupalLogin($admin_user); - foreach (['Save and unpublish' => FALSE, 'Save and keep unpublished' => FALSE, 'Save and publish' => TRUE, 'Save and keep published' => TRUE] as $submit => $visible) { - $edit = [ - 'menu[enabled]' => 1, - 'menu[title]' => $node_title, - ]; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, $submit); - // Assert that the link exists. - $this->drupalGet('test-page'); - if ($visible) { - $this->assertLink($node_title, 0, 'Found a menu link after submitted with ' . $submit); - } - else { - $this->assertNoLink($node_title, 'Found no menu link after submitted with ' . $submit); - } - } - - // Log back in as normal user. - $this->drupalLogin($this->editor); // Edit the node and create a menu link. $edit = array( 'menu[enabled]' => 1, diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 118e862..794fa61 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -399,11 +399,18 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['status'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Publishing status')) - ->setDescription(t('A boolean indicating whether the node is published.')) + ->setLabel(t('Published')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) - ->setDefaultValue(TRUE); + ->setDefaultValue(TRUE) + ->setDisplayOptions('form', array( + 'type' => 'boolean_checkbox', + 'settings' => array( + 'display_label' => TRUE, + ), + 'weight' => 120, + )) + ->setDisplayConfigurable('form', TRUE); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Authored on')) diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index bb6c49d..7a66c8b 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -241,59 +241,6 @@ protected function actions(array $form, FormStateInterface $form_state) { $element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || $this->hasBeenPreviewed; - // If saving is an option, privileged users get dedicated form submit - // buttons to adjust the publishing status while saving in one go. - // @todo This adjustment makes it close to impossible for contributed - // modules to integrate with "the Save operation" of this form. Modules - // need a way to plug themselves into 1) the ::submit() step, and - // 2) the ::save() step, both decoupled from the pressed form button. - if ($element['submit']['#access'] && \Drupal::currentUser()->hasPermission('administer nodes')) { - // isNew | prev status » default & publish label & unpublish label - // 1 | 1 » publish & Save and publish & Save as unpublished - // 1 | 0 » unpublish & Save and publish & Save as unpublished - // 0 | 1 » publish & Save and keep published & Save and unpublish - // 0 | 0 » unpublish & Save and keep unpublished & Save and publish - - // Add a "Publish" button. - $element['publish'] = $element['submit']; - // If the "Publish" button is clicked, we want to update the status to "published". - $element['publish']['#published_status'] = TRUE; - $element['publish']['#dropbutton'] = 'save'; - if ($node->isNew()) { - $element['publish']['#value'] = t('Save and publish'); - } - else { - $element['publish']['#value'] = $node->isPublished() ? t('Save and keep published') : t('Save and publish'); - } - $element['publish']['#weight'] = 0; - - // Add a "Unpublish" button. - $element['unpublish'] = $element['submit']; - // If the "Unpublish" button is clicked, we want to update the status to "unpublished". - $element['unpublish']['#published_status'] = FALSE; - $element['unpublish']['#dropbutton'] = 'save'; - if ($node->isNew()) { - $element['unpublish']['#value'] = t('Save as unpublished'); - } - else { - $element['unpublish']['#value'] = !$node->isPublished() ? t('Save and keep unpublished') : t('Save and unpublish'); - } - $element['unpublish']['#weight'] = 10; - - // If already published, the 'publish' button is primary. - if ($node->isPublished()) { - unset($element['unpublish']['#button_type']); - } - // Otherwise, the 'unpublish' button is primary and should come first. - else { - unset($element['publish']['#button_type']); - $element['unpublish']['#weight'] = -10; - } - - // Remove the "Save" button. - $element['submit']['#access'] = FALSE; - } - $element['preview'] = array( '#type' => 'submit', '#access' => $preview_mode != DRUPAL_DISABLED && ($node->access('create') || $node->access('update')), diff --git a/core/modules/node/src/Tests/NodeEditFormTest.php b/core/modules/node/src/Tests/NodeEditFormTest.php index f2701a4..5208b31 100644 --- a/core/modules/node/src/Tests/NodeEditFormTest.php +++ b/core/modules/node/src/Tests/NodeEditFormTest.php @@ -100,11 +100,13 @@ public function testNodeEdit() { $this->drupalLogin($second_web_user); // Edit the same node, creating a new revision. $this->drupalGet("node/" . $node->id() . "/edit"); - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(8); - $edit[$body_key] = $this->randomMachineName(16); - $edit['revision'] = TRUE; - $this->drupalPostForm(NULL, $edit, t('Save and keep published')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(8), + $body_key => $this->randomMachineName(16), + 'revision' => TRUE, + 'status[value]' => TRUE, + ); + $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the node revision has been created. $revised_node = $this->drupalGetNodeByTitle($edit['title[0][value]'], TRUE); @@ -127,10 +129,12 @@ public function testNodeEditAuthoredBy() { // Create node to edit. $body_key = 'body[0][value]'; - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(8); - $edit[$body_key] = $this->randomMachineName(16); - $this->drupalPostForm('node/add/page', $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(8), + $body_key => $this->randomMachineName(16), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/page', $edit, t('Save')); // Check that the node was authored by the currently logged in user. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); @@ -159,7 +163,10 @@ public function testNodeEditAuthoredBy() { $this->drupalLogin($this->adminUser); // Save the node without making any changes. - $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published')); + $edit = array( + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); $this->assertIdentical($this->webUser->id(), $node->getOwner()->id()); @@ -171,7 +178,10 @@ public function testNodeEditAuthoredBy() { // Check that saving the node without making any changes keeps the proper // author ID. - $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published')); + $edit = array( + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); $this->assertIdentical($this->webUser->id(), $node->getOwner()->id()); @@ -189,14 +199,18 @@ protected function checkVariousAuthoredByValues(NodeInterface $node, $form_eleme // Try to change the 'authored by' field to an invalid user name. $edit = array( $form_element_name => 'invalid-name', + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->assertRaw(t('There are no entities matching "%name".', array('%name' => 'invalid-name'))); // Change the authored by field to an empty string, which should assign // authorship to the anonymous user (uid 0). - $edit[$form_element_name] = ''; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $edit = array( + $form_element_name => '', + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); $uid = $node->getOwnerId(); @@ -207,8 +221,11 @@ protected function checkVariousAuthoredByValues(NodeInterface $node, $form_eleme // Change the authored by field to another user's name (that is not // logged in). - $edit[$form_element_name] = $this->webUser->getUsername(); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $edit = array( + $form_element_name => $this->webUser->getUsername(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->nodeStorage->resetCache(array($node->id())); $node = $this->nodeStorage->load($node->id()); $this->assertIdentical($node->getOwnerId(), $this->webUser->id(), 'Node authored by normal user.'); diff --git a/core/modules/node/src/Tests/NodeFormButtonsTest.php b/core/modules/node/src/Tests/NodeFormButtonsTest.php index 64ab29a..06416c4 100644 --- a/core/modules/node/src/Tests/NodeFormButtonsTest.php +++ b/core/modules/node/src/Tests/NodeFormButtonsTest.php @@ -51,10 +51,13 @@ function testNodeFormButtons() { $this->drupalGet('node/add/article'); $this->assertButtons(array(t('Save and publish'), t('Save as unpublished'))); - // Save the node and assert it's published after clicking - // 'Save and publish'. - $edit = array('title[0][value]' => $this->randomString()); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); + // Save the node and assert it's published after checking 'Published' + // boolean_checkbox and clicking 'Save'. + $edit = array( + 'title[0][value]' => $this->randomString(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/article', $edit, t('Save')); // Get the node. $node_1 = $node_storage->load(1); @@ -65,15 +68,18 @@ function testNodeFormButtons() { $this->assertButtons(array(t('Save and keep published'), t('Save and unpublish'))); // Save the node and verify it's still published after clicking - // 'Save and keep published'. - $this->drupalPostForm(NULL, $edit, t('Save and keep published')); + // 'Save'. + $this->drupalPostForm(NULL, $edit, t('Save')); $node_storage->resetCache(array(1)); $node_1 = $node_storage->load(1); $this->assertTrue($node_1->isPublished(), 'Node is published'); - // Save the node and verify it's unpublished after clicking - // 'Save and unpublish'. - $this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save and unpublish')); + // Save the node and verify it's unpublished after unchecking 'Published' + // boolean_checkbox and clicking 'Save'. + $edit = array( + 'status[value]' => FALSE, + ); + $this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save')); $node_storage->resetCache(array(1)); $node_1 = $node_storage->load(1); $this->assertFalse($node_1->isPublished(), 'Node is unpublished'); @@ -100,7 +106,10 @@ function testNodeFormButtons() { // was created by the normal user. $this->drupalLogout(); $this->drupalLogin($this->adminUser); - $this->drupalPostForm('node/' . $node_2->id() . '/edit', array(), t('Save and unpublish')); + $edit = array( + 'status[value]' => FALSE, + ); + $this->drupalPostForm('node/' . $node_2->id() . '/edit', $edit, t('Save')); $node_storage->resetCache(array(2)); $node_2 = $node_storage->load(2); $this->assertFalse($node_2->isPublished(), 'Node is unpublished'); diff --git a/core/modules/node/src/Tests/NodeRevisionsUiTest.php b/core/modules/node/src/Tests/NodeRevisionsUiTest.php index a72142f..764cb74 100644 --- a/core/modules/node/src/Tests/NodeRevisionsUiTest.php +++ b/core/modules/node/src/Tests/NodeRevisionsUiTest.php @@ -59,8 +59,11 @@ function testNodeFormSaveWithoutRevision() { $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); // Uncheck the create new revision checkbox and save the node. - $edit = array('revision' => FALSE); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $edit = array( + 'revision' => FALSE, + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Load the node again and check the revision is the same as before. $node_storage->resetCache(array($node->id())); @@ -72,8 +75,10 @@ function testNodeFormSaveWithoutRevision() { $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); // Submit the form without changing the checkbox. - $edit = array(); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $edit = array( + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Load the node again and check the revision is different from before. $node_storage->resetCache(array($node->id())); diff --git a/core/modules/options/src/Tests/OptionsFieldUITest.php b/core/modules/options/src/Tests/OptionsFieldUITest.php index d4219c6..cd9de97 100644 --- a/core/modules/options/src/Tests/OptionsFieldUITest.php +++ b/core/modules/options/src/Tests/OptionsFieldUITest.php @@ -330,9 +330,10 @@ function testNodeDisplay() { // Select a default value. $edit = array( - $this->fieldName => '1', + $this->fieldName => TRUE, + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); // Check the node page and see if the values are correct. $file_formatters = array('list_default', 'list_key'); diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php index 5c2a1c2..beff581 100644 --- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php @@ -50,8 +50,11 @@ protected function setUp() { // Link the node to itself to test that it's only indexed once. The content // also needs the word "pizza" so we can use it as the search keyword. $body_key = 'body[0][value]'; - $edit[$body_key] = \Drupal::l($node->label(), $node->urlInfo()) . ' pizza sandwich'; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); + $edit = array( + $body_key => \Drupal::l($node->label(), $node->urlInfo()) . ' pizza sandwich', + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); search_update_totals(); diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index 6548208..6ff9d57 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -210,8 +210,9 @@ function testBreadCrumbs() { $edit = array( 'menu[menu_parent]' => $link->getMenuName() . ':' . $link->getPluginId(), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save')); $expected = array( "node" => $link->getTitle(), ); @@ -231,8 +232,9 @@ function testBreadCrumbs() { ); $edit = array( 'field_tags[target_id]' => implode(',', array_keys($tags)), + 'status[value]' => TRUE, ); - $this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save and keep published')); + $this->drupalPostForm('node/' . $parent->id() . '/edit', $edit, t('Save')); // Put both terms into a hierarchy Drupal » Breadcrumbs. Required for both // the menu links and the terms itself, since taxonomy_term_page() resets diff --git a/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php b/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php index fa14999..b096042 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php +++ b/core/modules/system/src/Tests/Update/UpdatePathRC1TestBaseFilledTest.php @@ -122,7 +122,10 @@ public function testUpdatedSite() { $this->assertText('Test Article - New title'); $this->assertText('Test 1'); $this->assertRaw('0.01'); - $this->drupalPostForm('node/8/edit', [], 'Save and keep published (this translation)'); + $edit = array( + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/8/edit', $edit, 'Save (this translation)'); $this->assertResponse(200); $this->drupalGet('node/8/edit', ['language' => $spanish]); $this->assertText('Test title Spanish'); diff --git a/core/modules/taxonomy/src/Tests/LegacyTest.php b/core/modules/taxonomy/src/Tests/LegacyTest.php index 06966b8..2110338 100644 --- a/core/modules/taxonomy/src/Tests/LegacyTest.php +++ b/core/modules/taxonomy/src/Tests/LegacyTest.php @@ -58,13 +58,15 @@ protected function setUp() { function testTaxonomyLegacyNode() { // Posts an article with a taxonomy term and a date prior to 1970. $date = new DrupalDateTime('1969-01-01 00:00:00'); - $edit = array(); - $edit['title[0][value]'] = $this->randomMachineName(); - $edit['created[0][value][date]'] = $date->format('Y-m-d'); - $edit['created[0][value][time]'] = $date->format('H:i:s'); - $edit['body[0][value]'] = $this->randomMachineName(); - $edit['field_tags[target_id]'] = $this->randomMachineName(); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); + $edit = array( + 'title[0][value]' => $this->randomMachineName(), + 'created[0][value][date]' => $date->format('Y-m-d'), + 'created[0][value][time]' => $date->format('H:i:s'), + 'body[0][value]' => $this->randomMachineName(), + 'field_tags[target_id]' => $this->randomMachineName(), + 'status[value]' => TRUE, + ); + $this->drupalPostForm('node/add/article', $edit, t('Save')); // Checks that the node has been saved. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.'); diff --git a/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml b/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml index 189737c..ad66820 100644 --- a/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml +++ b/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml @@ -58,6 +58,12 @@ content: display_label: true weight: 15 third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 100 + third_party_settings: { } sticky: type: boolean_checkbox settings: diff --git a/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml index 1fef06d..785e17f 100644 --- a/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml +++ b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml @@ -36,6 +36,12 @@ content: display_label: true weight: 15 third_party_settings: { } + status: + type: boolean_checkbox + settings: + display_label: true + weight: 100 + third_party_settings: { } sticky: type: boolean_checkbox settings: