.../Core/Field/Plugin/Field/FieldFormatter/AuthorFormatter.php | 3 +++ .../Field/Plugin/Field/FieldWidget/AuthorAutocompleteWidget.php | 2 +- core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php | 2 +- core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php | 7 ++++--- core/modules/node/node.module | 1 + .../lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php | 2 -- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/AuthorFormatter.php index 5b5be15..2410202 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/AuthorFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/AuthorFormatter.php @@ -37,6 +37,9 @@ public function viewElements(FieldItemListInterface $items) { '#theme' => 'username', '#account' => $referenced_user, '#link_options' => array('attributes' => array('rel' => 'author')), + '#cache' => array( + 'tags' => $referenced_user->getCacheTag(), + ), ); } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/AuthorAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/AuthorAutocompleteWidget.php index 9c79397..560cfb1 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/AuthorAutocompleteWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/AuthorAutocompleteWidget.php @@ -33,7 +33,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element = parent::formElement($items, $delta, $element, $form, $form_state); $entity = $element['#entity']; - $element['target_id']['#default_value'] = $entity->getOwner()? $entity->getOwner()->getUsername() : ''; + $element['target_id']['#default_value'] = $entity->getOwner()->isAuthenticated() ? $entity->getOwner()->getUsername() : ''; $user_config = \Drupal::config('user.settings'); $element['target_id']['#description'] = $this->t('Leave blank for %anonymous.', array('%anonymous' => $user_config->get('anonymous'))); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php index f0c85c1..962f2f8 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php @@ -65,7 +65,7 @@ protected function createEntity() { * Each node must have an author. */ protected function getAdditionalCacheTagsForEntity(EntityInterface $node) { - return array('user:' . $node->getOwnerId(), 'user_view:' . TRUE); + return array('user:' . $node->getOwnerId()); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php index 1f39201..4fcf3db 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php @@ -62,9 +62,9 @@ function testNodeCreation() { $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); + $this->assertNoText($node->getOwner()->getUsername()); + $this->assertNoText(format_date($node->getCreatedTime())); // Change the node type setting to show submitted by information. $node_type = entity_load('node_type', 'page'); @@ -72,7 +72,8 @@ function testNodeCreation() { $node_type->save(); $this->drupalGet('node/' . $node->id()); - $this->assertText($submitted_by); + $this->assertText($node->getOwner()->getUsername()); + $this->assertText(format_date($node->getCreatedTime())); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 268dc7f..b8d7f2c 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -632,6 +632,7 @@ function template_preprocess_node(&$variables) { $variables['date'] = drupal_render($variables['elements']['created'], TRUE); unset($variables['elements']['created']); $variables['name'] = drupal_render($variables['elements']['uid'], TRUE); + unset($variables['elements']['uid']); $variables['node_url'] = $node->url('canonical', array( 'language' => $node->language(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php index be45fff..f310b24 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -93,7 +93,6 @@ function testPageCacheTags() { 'node_view:1', 'node:' . $node_1->id(), 'user:' . $author_1->id(), - 'user_view:' . TRUE, 'filter_format:basic_html', 'menu:tools', 'menu:footer', @@ -121,7 +120,6 @@ function testPageCacheTags() { 'node_view:1', 'node:' . $node_2->id(), 'user:' . $author_2->id(), - 'user_view:' . TRUE, 'filter_format:full_html', 'menu:tools', 'menu:footer',