From 713294e96e791fc7aaab7ded3f01a288d9263eef Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 29 Jun 2018 23:34:57 +0100 Subject: [PATCH] Issue #2887490 by michaellenahan, cilefen, rOprOprOp, catch: Activity Tracker cannot be enabled if there are unpublished nodes --- .../tracker/tests/src/Functional/TrackerTest.php | 10 ++++++++-- core/modules/tracker/tracker.module | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php index 1a77d95ac89..ac193909b39 100644 --- a/core/modules/tracker/tests/src/Functional/TrackerTest.php +++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php @@ -361,8 +361,14 @@ class TrackerTest extends BrowserTestBase { ]; $this->drupalPostForm('comment/reply/node/' . $nodes[3]->id() . '/comment', $comment, t('Save')); - // Start indexing backwards from node 3. - \Drupal::state()->set('tracker.index_nid', 3); + // Create an unpublished node. + $unpublished = $this->drupalCreateNode([ + 'title' => $this->randomMachineName(8), + 'status' => 0, + ]); + + // Start indexing backwards from node 4. + \Drupal::state()->set('tracker.index_nid', 4); // Clear the current tracker tables and rebuild them. db_delete('tracker_node') diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index bf40dc1e8dc..dadefecabc8 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -72,7 +72,7 @@ function tracker_cron() { db_insert('tracker_node') ->fields([ 'nid' => $nid, - 'published' => $node->isPublished(), + 'published' => (int) $node->isPublished(), 'changed' => $changed, ]) ->execute(); @@ -81,7 +81,7 @@ function tracker_cron() { db_insert('tracker_user') ->fields([ 'nid' => $nid, - 'published' => $node->isPublished(), + 'published' => (int) $node->isPublished(), 'changed' => $changed, 'uid' => $node->getOwnerId(), ])