diff --git a/core/modules/node/node.js b/core/modules/node/node.js index 7e088ef..298bcb9 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -27,8 +27,8 @@ $context.find('.node-form-author').drupalSetSummary(function (context) { var $context = $(context); - var name = $context.find('.form-item-name input').val() || drupalSettings.anonymous, - date = $context.find('.form-item-date input').val(); + var name = $context.find('.field-name-uid input').val() || drupalSettings.anonymous, + date = $context.find('.field-name-created input').val(); return date ? Drupal.t('By @name on @date', { '@name': name, '@date': date }) : Drupal.t('By @name', { '@name': name }); diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 823e5d8..0fe594e 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -378,6 +378,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'default_value' => 0, 'handler' => 'default', )) + ->setDefaultValueCallback(array('\Drupal', 'currentUser')) ->setTranslatable(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 4a4a8fe..beae4b2 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; +use Drupal\user\Entity\User; /** * Form controller for the node edit forms. @@ -378,15 +379,15 @@ public function buildEntity(array $form, FormStateInterface $form_state) { $entity = parent::buildEntity($form, $form_state); // A user might assign the node author by entering a user name in the node // form, which we then need to translate to a user ID. - if (!$form_state->isValueEmpty('uid') && $account = user_load_by_name($form_state->getValue('uid'))) { + if (!$form_state->isValueEmpty('uid') && $account = User::load($form_state->getValue('uid')[0]['target_id'])) { $entity->setOwnerId($account->id()); } else { $entity->setOwnerId(0); } - if (!$form_state->isValueEmpty('created') && $form_state->getValue('created') instanceOf DrupalDateTime) { - $entity->setCreatedTime($form_state->getValue('created')->getTimestamp()); + if (!$form_state->isValueEmpty('created')) { + $entity->setCreatedTime($form_state->getValue('created')[0]['value']); } else { $entity->setCreatedTime(REQUEST_TIME);