diff -u b/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php --- b/core/modules/tracker/tests/src/Functional/TrackerTest.php +++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php @@ -142,21 +142,21 @@ public function testTrackerUser() { $this->drupalLogin($this->user); - $this->nodes = []; - $this->nodes['unpublished'] = $this->drupalCreateNode([ + $nodes = []; + $nodes['unpublished'] = $this->drupalCreateNode([ 'title' => $this->randomMachineName(8), 'uid' => $this->user->id(), 'status' => 0, ]); - $this->nodes['my_published'] = $this->drupalCreateNode([ + $nodes['my_published'] = $this->drupalCreateNode([ 'title' => $this->randomMachineName(8), 'uid' => $this->user->id(), 'status' => 1, ]); $this->drupalGet('user/' . $this->user->id() . '/activity'); - $this->assertSession()->pageTextNotContains($this->nodes['unpublished']->label(), "Unpublished nodes do not show up in the user's tracker listing."); - $this->assertSession()->pageTextContains($this->nodes['my_published']->label(), "Published nodes show up in the user's tracker listing."); + $this->assertSession()->pageTextNotContains($nodes['unpublished']->label(), "Unpublished nodes do not show up in the user's tracker listing."); + $this->assertSession()->pageTextContains($nodes['my_published']->label(), "Published nodes show up in the user's tracker listing."); // Assert cache contexts. $this->assertCacheContexts([ @@ -170,7 +170,7 @@ ); // Assert cache tags for the visible nodes (including owners) and node list // cache tag. - $expected_tags = Cache::mergeTags($this->nodes['my_published']->getCacheTags(), $this->nodes['my_published']->getOwner()->getCacheTags()); + $expected_tags = Cache::mergeTags($nodes['my_published']->getCacheTags(), $nodes['my_published']->getOwner()->getCacheTags()); // Because the 'user.permissions' cache context is being optimized away. $role_tags = []; foreach ($this->user->getRoles() as $rid) { @@ -203,8 +203,8 @@ ] ); - $this->assertSession()->linkExists($this->nodes['my_published']->label()); - $this->assertSession()->linkNotExists($this->nodes['unpublished']->label()); + $this->assertSession()->linkExists($nodes['my_published']->label()); + $this->assertSession()->linkNotExists($nodes['unpublished']->label()); // Verify that title and tab title have been set correctly. $this->assertSession()->pageTextContains('Activity'); $this->assertSession()->titleEquals($this->user->getAccountName() . ' | Drupal'); @@ -233,16 +233,15 @@ $edit = [ 'title' => $this->randomMachineName(8), ]; - $this->node = $this->drupalCreateNode($edit); + $node = $this->drupalCreateNode($edit); // Verify that the history metadata is present. $this->drupalGet('activity'); - $this->assertHistoryMetadata($this->node->id(), $this->node->getChangedTime()); + $this->assertHistoryMetadata($node->id(), $node->getChangedTime()); $this->drupalGet('activity/' . $this->user->id()); - $this->assertHistoryMetadata($this->node->id(), $this->node->getChangedTime()); + $this->assertHistoryMetadata($node->id(), $node->getChangedTime()); $this->drupalGet('user/' . $this->user->id() . '/activity'); - $this->assertHistoryMetadata($this->node->id(), $this->node->getChangedTime()); - + $this->assertHistoryMetadata($node->id(), $node->getChangedTime()); } /** @@ -368,11 +367,13 @@ * * @internal */ - public function assertHistoryMetadata(int $node_id, int $node_timestamp, int $node_last_comment_timestamp, bool $library_is_present = TRUE): void { + public function assertHistoryMetadata(int $node_id, int $node_timestamp, int $node_last_comment_timestamp = NULL, bool $library_is_present = TRUE): void { $settings = $this->getDrupalSettings(); $this->assertSame($library_is_present, isset($settings['ajaxPageState']) && in_array('tracker/history', explode(',', $settings['ajaxPageState']['libraries'])), 'drupal.tracker-history library is present.'); $this->assertCount(1, $this->xpath('//table/tbody/tr/td[@data-history-node-id="' . $node_id . '" and @data-history-node-timestamp="' . $node_timestamp . '"]'), 'Tracker table cell contains the data-history-node-id and data-history-node-timestamp attributes for the node.'); - $this->assertCount(1, $this->xpath('//table/tbody/tr/td[@data-history-node-last-comment-timestamp="' . $node_last_comment_timestamp . '"]'), 'Tracker table cell contains the data-history-node-last-comment-timestamp attribute for the node.'); + if (isset($node_last_comment_timestamp)) { + $this->assertCount(1, $this->xpath('//table/tbody/tr/td[@data-history-node-last-comment-timestamp="' . $node_last_comment_timestamp . '"]'), 'Tracker table cell contains the data-history-node-last-comment-timestamp attribute for the node.'); + } } } diff -u b/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module --- b/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -104,7 +104,7 @@ ->groupBy('uid') ->execute(); if ($result) { - $query = db_insert('tracker_user'); + $query = $connection->insert('tracker_user'); foreach ($result as $row) { $query->fields([ 'uid' => $row['uid'],