diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 82a3dab..4b96220 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -280,7 +280,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['status'] = FieldDefinition::create('boolean') ->setLabel(t('Publishing status')) - ->setDescription(t('A boolean indicating whether the comment is published.')); + ->setDescription(t('A boolean indicating whether the comment is published.')) + ->setSetting('default_value', TRUE); $fields['thread'] = FieldDefinition::create('string') ->setLabel(t('Thread place')) diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentBookTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentBookTest.php index a8847f4..4d92e9d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentBookTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentBookTest.php @@ -45,7 +45,6 @@ public function testBookCommentPrint() { 'type' => 'book', 'title' => 'Book title', 'body' => 'Book body', - 'status' => NODE_PUBLISHED, )); $book_node->book['bid'] = 'new'; $book_node->save(); diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 3d6b87e..700d824 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -94,10 +94,6 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco if (!isset($record->log)) { $record->log = ''; } - // Ensure we have a valid value for the revision author. - if (!isset($record->revision_uid)) { - $record->revision_uid = 0; - } } elseif (isset($this->original) && (!isset($record->log) || $record->log === '')) { // If we are updating an existing node without adding a new revision, we @@ -399,6 +395,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['status'] = FieldDefinition::create('boolean') ->setLabel(t('Publishing status')) ->setDescription(t('A boolean indicating whether the node is published.')) + ->setSetting('default_value', NODE_PUBLISHED) ->setRevisionable(TRUE) ->setTranslatable(TRUE); @@ -436,7 +433,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['revision_uid'] = FieldDefinition::create('entity_reference') ->setLabel(t('Revision user ID')) ->setDescription(t('The user ID of the author of the current revision.')) - ->setSettings(array('target_type' => 'user')) + ->setSettings(array('target_type' => 'user', 'default_value' => 0)) ->setQueryable(FALSE) ->setRevisionable(TRUE); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 4ad2054..14c6a81 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -352,6 +352,8 @@ protected function installEntitySchema($entity_type_id) { foreach ($schema as $table_name => $table_schema) { $schema_handler->createTable($table_name, $table_schema); } + // TODO Refactor schema installation code in entity.module to make it reusable. + $this->container->get('module_handler')->invokeAll('entity_schema_installed', array(array($entity_type_id => $storage))); $this->pass(String::format('Installed entity type tables for the %entity_type entity type: %tables', array( '%entity_type' => $entity_type_id, '%tables' => '{' . implode('}, {', array_keys($schema)) . '}', diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 3023e9f..d9a3545 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -507,6 +507,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['status'] = FieldDefinition::create('boolean') ->setLabel(t('User status')) ->setDescription(t('Whether the user is active (1) or blocked (0).')) + // TODO This should be FALSE. ->setSetting('default_value', 1); $fields['created'] = FieldDefinition::create('created') diff --git a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php index a21aaf1..a2f6c4a 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php @@ -37,6 +37,7 @@ public static function getInfo() { */ protected function setUp() { parent::setUp(); + $this->container->get('module_handler')->loadInclude('user', 'install'); $this->installEntitySchema('user'); }