diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php index ec465e1..76786d1 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php @@ -31,13 +31,6 @@ public function form(array $form, array &$form_state) { } $node_settings = $type->getModuleSettings('node'); - // Ensure default settings. - $node_settings += array( - 'options' => array('status', 'promote'), - 'preview' => DRUPAL_OPTIONAL, - 'submitted' => TRUE, - ); - $form['name'] = array( '#title' => t('Name'), '#type' => 'textfield', diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php index 464fbe0..650e8be 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php @@ -215,4 +215,21 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont } } + /** + * {@inheritdoc} + */ + public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { + parent::preCreate($storage_controller, $values); + + // Ensure default values are set. + if (!isset($values['settings']['node'])) { + $values['settings']['node'] = array(); + } + $values['settings']['node'] += array( + 'options' => array('status', 'promote'), + 'preview' => DRUPAL_OPTIONAL, + 'submitted' => TRUE, + ); + } + } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php index 90592b0..d6a6399 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php @@ -56,6 +56,19 @@ function testNodeCreation() { // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($edit["title"]); $this->assertTrue($node, 'Node found in database.'); + + // Verify that pages do not show submitted information by default. + $submitted_by = t('Submitted by !username on !datetime', array('!username' => $this->loggedInUser->getUsername(), '!datetime' => format_date($node->getCreatedTime()))); + $this->drupalGet('node/' . $node->id()); + $this->assertNoText($submitted_by); + + // Change the node type setting to show submitted by information. + $node_type = entity_load('node_type', 'page'); + $node_type->settings['node']['submitted'] = TRUE; + $node_type->save(); + + $this->drupalGet('node/' . $node->id()); + $this->assertText($submitted_by); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php index b52d825..7699dff 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php @@ -108,8 +108,7 @@ function testNodeFormButtons() { // Set article content type default to unpublished. This will change the // the initial order of buttons and/or status of the node when creating // a node. - variable_set('node_options_article', array('promote')); - config('node.type.article')->set('settings.node.options.status', 0)->save(); + \Drupal::config('node.type.article')->set('settings.node.options', array('promote'))->save(); // Verify the buttons on a node add form for an administrator. $this->drupalLogin($this->admin_user); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php b/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php index 93eb3dd..bd2c476 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php @@ -27,7 +27,7 @@ function setUp() { // Create Basic page and Article node types. if ($this->profile != 'standard') { - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page', 'settings' => array('node' => array('submitted' => FALSE)))); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 26f11a2..eb0600a 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -714,8 +714,7 @@ function template_preprocess_node(&$variables) { // Display post information only on certain node types. // Avoid loading the entire node type config entity here. - $submitted = Drupal::config('node.type.' . $node->bundle())->get('settings.node.submitted') ?: TRUE; - if ($submitted) { + if (Drupal::config('node.type.' . $node->bundle())->get('settings.node.submitted')) { $variables['display_submitted'] = TRUE; $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); if (theme_get_setting('features.node_user_picture')) { diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php index 62767a6..302a260 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php @@ -284,7 +284,7 @@ protected function doArticleRdfaTests() { protected function doPageRdfaTests() { // The standard profile hides the created date on pages. Revert display to // true for testing. - variable_set('node_submitted_page', TRUE); + \Drupal::config('node.type.page')->set('settings.node.submitted', TRUE); // Feed the HTML into the parser. $uri_info = $this->page->uri(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index ab24fc8..bc66abe 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -285,6 +285,10 @@ protected function drupalCreateNode(array $settings = array()) { 'format' => filter_default_format(), ); + // If the specified node type does not exist, create it. + if (!$this->container->get('entity.query')->get('node_type')->condition('type', $settings['type'])->execute()) { + $this->drupalCreateContentType(array('type' => $settings['type'], 'name' => $this->randomString())); + } $node = entity_create('node', $settings); if (!empty($settings['revision'])) { $node->setNewRevision();