Problem/Motivation

Core tracker only tracks changes to the owner of the node. If uid=1 edits the node, but the node was owned/created by 1523, it gets tracked as edited by 1523.

Proposed resolution

Track more correctly.

Remaining tasks

Roll a patch

Issue fork tracker-3106371

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

heddn created an issue. See original summary.

heddn’s picture

Title: Tracker only tracks changes to the node owner » Tracker only tracks changes by the node owner
Status: Active » Needs review
Related issues: +#3105711: tracker_cron() queries are missing ->accessCheck(FALSE)
StatusFileSize
new679 bytes

This tracks by the user performing the update instead of just the node owner.

catch’s picture

This seems like a good idea.

Are we able to use the revision author value instead of relying on the current user?

Also we should make the same change in the tracker_cron() logic.

heddn’s picture

StatusFileSize
new4.5 KB
new4.61 KB

That ended up being more complicated then I expected to alter the cron implementation. This uses db merge a lot more often because we need to load all revisions and process them one by one. And its possible that one of the revisions could have been written by another author or be a comment by another author that already is recorded in the tracker system.

xjm’s picture

Version: 9.0.x-dev » 9.1.x-dev

Even though this is a bugfix, I think it's a minor-only change, since it's changing the behavior of the module. So, moving to 9.1.x-dev. Thanks!

kristen pol’s picture

Tested the changes for tracker_node_update as follows but not the cron code since I'm not sure how to test the cron code:

1) Enable Activity Tracker module

2) Create additional user account (username=hello)

3) Add Article content with author of hello

4) Check /user/[new user id]/activity and only relevant "hello" activity should show up

5) Add Article content with author of user 1

6) Check /user/1/activity and only relevant user 1 activity should show up

7) Update user 1's content by user 1

8) Update hello's content by user 1

9) Check /user/1/activity and only relevant user 1 activity should show up

10) Check /user/[new user id]/activity and only relevant "hello" activity should show up

While it works as expected, the table shows "Last updated" which is technically correct though maybe it would make sense to show "Last updated by me" since that might more relevant but it really depends on what the user is looking for.

Without patch:

With patch:

kristen pol’s picture

StatusFileSize
new84.25 KB

Fixing one of the screenshots.

kristen pol’s picture

Issue tags: +Bug Smash Initiative

Adding tag as I worked on this yesterday for the Bug Smash Initiative.

Also, if someone can provide notes/steps for testing the cron, that would be great.

jibran’s picture

Issue tags: +Needs tests

Let's add some tests here.

kristen pol’s picture

Status: Needs review » Needs work

Back to "Needs work" for tests.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

mohit_aghera’s picture

Assigned: Unassigned » mohit_aghera
Status: Needs work » Needs review
StatusFileSize
new6.89 KB
new2.29 KB

Uploading test to evaluate scenarios mentioned above.

mohit_aghera’s picture

Assigned: mohit_aghera » Unassigned
pragati_kanade’s picture

Status: Needs review » Needs work

I have tested this patch. Patch is not applying correctly. Need to re-roll it.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new6.98 KB

Re-rolled patch. Please review.

Status: Needs review » Needs work

The last submitted patch, 15: 3106371-15.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new6.92 KB
new2.36 KB

- Fixing the issue in re-roll which was causing test-case failures.
In comment #12, _tracker_add($node->id(), $node->getRevisionUserId(), $node->getChangedTime()); snippet was in tracker_node_update hook.
- Remove deprecated functions from test cases.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Thanks for the update. I'm confused on this part:

+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -474,4 +474,35 @@ public function assertHistoryMetadata($node_id, $node_timestamp, $node_last_comm
+    // Login with other user and update the node.
+    $updated_title = 'Test Article from ' . $this->otherUser->getAccountName();
+    $this->drupalLogin($this->otherUser);
+
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $edit['title[0][value]'] = 'Test Article from ' . $this->otherUser->getAccountName();
+    $this->submitForm($edit, 'Save');

Wouldn't it be better to be something like this?

+    // Login with other user and update the node.
+    $this->drupalLogin($this->otherUser);
+    $updated_title = 'Test Article from ' . $this->otherUser->getAccountName();
+
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $edit['title[0][value]'] = $updated_title;
+    $this->submitForm($edit, 'Save');

i.e. reuse $updated_title?

mohit_aghera’s picture

StatusFileSize
new6.87 KB
new721 bytes

@Kristen Pol, thanks for the heads up!!
It was surely a miss. Fixed it.

kristen pol’s picture

Thanks for the update. The interdiff change looks good. Some thoughts :)

1) Next time, it would be good to have a test only patch added first, so we see it fails without the fix.

2) Don't we also need a test for the cron?

3) I'm not sure how to manually test the cron.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

catch’s picture

Status: Needs work » Postponed

Tracker is deprecated for removal in Drupal 11, this issue can be moved to the contributed module once the Drupal 11 branch is open.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Project: Drupal core » Activity Tracker
Version: 11.x-dev » 1.0.x-dev
Component: tracker.module » Code
Status: Postponed » Needs work
Related issues: +#1058284: Make Tracker recognize node revisions, +#762962: Add permissions for the tracker pages
brad.bulger’s picture

I am applying the patch in #20 to this contrib version of tracker, it works without issue.

batigolix made their first commit to this issue’s fork.

batigolix’s picture

I created a MR from the patch

batigolix’s picture

Status: Needs work » Needs review