"Recent content", the page coming from tracker module doesn't work properly.

The "new comments" link is not displayed.

Steps to reproduce:

1. Install brand new site.
2. Log in with the admin user.
3. Enable tracker module.
4. Create another user, and make it admin (just for permissions sake).
5. Open incognito or a different browser and log in with the second user).
6. Create an article and forum post with the second user.
7. Comment on the article and forum post with the second user.
8. Go to /activity on the first user.

You should see "1 new" on the comments tab, but it doesn't show.

The request to: http://drupal86.dev.localhost/comments/render_new_comments_node_links

Returns:

TypeError: Argument 1 passed to Drupal\comment\CommentManager::getCountNewComments() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /Users/ariel/Sites/drupal/drupal86.git/core/modules/comment/src/Controller/CommentController.php on line 333 in Drupal\comment\CommentManager->getCountNewComments() (line 180 of /Users/ariel/Sites/drupal/drupal86.git/core/modules/comment/src/CommentManager.php).

This is actually because the POST node_ids[] are null, and the reason for that is #2915993: Adjust render_new_comments_node_links to fix issues, which is the traversing of the table column HTML tags could fail on some browsers/OSs/themes. However, even by fixing that, you also get:

Error: Call to a member function getSetting() on null in Drupal\comment\CommentStorage->getNewCommentPageNumber() (line 135 of /Users/ariel/Sites/drupal/drupal86.git/core/modules/comment/src/CommentStorage.php).

And the reason for that is also both mentioned on the comments here and on #2915993: Adjust render_new_comments_node_links to fix issues and is because you are not sending anywhere the comment field name and that's needed for this to work.

No interdiff really as it's a whole different approach.

jurgenhaas that did #2915993: Adjust render_new_comments_node_links to fix issues deserves credit too if this one moves forward.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jeff Burnz created an issue. See original summary.

larowlan’s picture

What do you mean by Recent Content?

Jeff Burnz’s picture

The URL is in the error message: http://d8head:8888/activity/1 this is page titled "Recent Content" that displays a table with recently added content, you need the Activity Tracker module enabled and the link is in the Tools menu.

dawehner’s picture

Version: 8.1.x-dev » 8.0.x-dev

Bugfixes should be fixed against 8.0.x, IMHO

larowlan’s picture

Assigned: Unassigned » larowlan

digging in

larowlan’s picture

Assigned: larowlan » Unassigned
Status: Active » Needs review
Issue tags: +JavaScript
FileSize
2.08 KB

Not sure we can test this without JavaScript testing.
This bring tracker-history.js into line with node-new-comment-links.js

larowlan’s picture

Component: comment.module » tracker.module

The bug is in tracker module code

andypost’s picture

Issue tags: +Needs manual testing

Also history module related

catch’s picture

Priority: Normal » Major
Status: Needs review » Needs work

I think the history callback should validate the arguments it gets too. Can't find it right now but there's a similar issue open for the nid being out of range.

You could manually trigger the PHP error here which isn't great (especially if load balancers take 5* errors as a sign to take nodes out of rotation).

andypost’s picture

andypost’s picture

Status: Needs work » Needs review
Issue tags: -Needs manual testing +Needs tests
FileSize
776 bytes

I can't reproduce that on /activity/1 anymore
maybe something was fixed already? or that was some caching issue

Anyway something like the patch is needed with test coverage

Berdir’s picture

Status: Needs review » Needs work

Needs work for test coverage then.

Also if you convert this to do a loadMultiple($nids) as $node then you've solved the problem too. A node that can't be loaded will never go into the loop. And performance is better.

andypost’s picture

@Berdir I wanna to convert that to load multiple long ago, but each time that out of scope ;)

There's actually 3 problems here:
1) JS passed only node Ids - manager call will be broken (no idea how reproduce) so @larowlan patch makes sense but that's a front side
2) Nodes could have different comment fields (names of fields) so $node->{wrong_field_name} will throw this exception too
3) no check for access/existence of nodes (my patch) should be refactored to load multiple call.

+++ b/core/modules/tracker/js/tracker-history.js
@@ -105,7 +107,7 @@
-      data: {'node_ids[]': nodeIDs},
+      data: {'node_ids[]': nodeIDs, 'field_name': 'comment'},

request should carry field name for each node or group them

SerShevchyk’s picture

I think we need replace 'comment' with name of last comment field, but we have empty value last_comment_name in $node in tracker.pages.inc

andypost’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: 2620748-13.patch, failed testing.

andypost’s picture

+++ b/core/modules/comment/src/Controller/CommentController.php
@@ -325,7 +325,11 @@ public function renderNewCommentsNodeLinks(Request $request) {
     $field_name = $request->request->get('field_name');
+
     if (!isset($nids)) {
       throw new NotFoundHttpException();

+++ b/core/modules/tracker/js/tracker-history.js
@@ -105,7 +105,7 @@
+      data: {'node_ids[]': nodeIDs,'field_name': fieldName},

the field name could be different for each node and not only one

andypost’s picture

Status: Needs work » Needs review
FileSize
2 KB

The proper controller code, JS side should be fixed like #14

  1. +++ b/core/modules/tracker/js/tracker-history.js
    @@ -105,7 +105,7 @@
    -      data: {'node_ids[]': nodeIDs},
    +      data: {'node_ids[]': nodeIDs,'field_name': fieldName},
    

    pass a field_name is a requirement

  2. +++ b/core/modules/tracker/tracker.pages.inc
    @@ -104,6 +105,7 @@ function tracker_page($account = NULL) {
    +          'data-history-node-last-comment-name' => 'comment',
    

    yep! but needs to check a views plugins as well, to properly fix all over

Status: Needs review » Needs work

The last submitted patch, 18: 2620748-18.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
859 bytes
2 KB

Status: Needs review » Needs work

The last submitted patch, 20: 2620748-20.patch, failed testing.

xjm’s picture

The comments on this issue confuse me because they almost seem to be about different bugs; can we update the issue summary with steps to reproduce this issue?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

hanoii’s picture

A similar issue with a similar patch is on #2915993: Adjust render_new_comments_node_links to fix issues. That covers another thing too which is related to the traversing of the siblings not coping very nicely with other themes. I think I'll try to make the other issue more into the traversing and leave this one for the missing field_name which is indeed a bug.

hanoii’s picture

After further looking at this, the real reason behind this is actually what was first described on #2915993: Adjust render_new_comments_node_links to fix issues, at first I was going to keep both separated, but they are the same thing. I am gonna mark the other one duplicate and improve this one.

hanoii’s picture

Title: Recoverable fatal error: Argument 1 passed to Drupal\comment\CommentManager::getCountNewComments() » New comments link is not being displayed on activity pages
Issue summary: View changes
Issue tags: -Needs issue summary update
hanoii’s picture

This will likely go to needs work quick enough, but at least to prompt for some reviews.

This fixes this issue as well as #2915993: Adjust render_new_comments_node_links to fix issues.

It's simple in a way. The one thing that it's not really looking for is for the odd case of a node having more than one comment field. The tracker pages take that into consideration to displaying the total comments, but gets a lot trickier fi we want to support that and the "new comment link". It's likely a bug larger and broader issue.

I'd say we try to get this in in the best shape possible and work on the wider issue further along the way, as this will at least make most installs actually work. I am surprised this hasn't come up more often. I guess the tracker module is not widely used?

hanoii’s picture

Version: 8.5.x-dev » 8.6.x-dev

Patch is for 8.6.x

hanoii’s picture

Issue summary: View changes

jurgenhaas that did #2915993: Adjust render_new_comments_node_links to fix issues deserves credit too if this one moves forward.

hanoii’s picture

This one is for D85, I need it on a project. The 8.6 doesn't apply because some code was moved from the bottom of the file to the top (or viceversa)

hanoii’s picture

So, both patches applies to both branches. It's odd. I can't apply #31 to 8.5.x with patch -p1 but I do with git apply and I guess that's what jenkins is doing. composer-patches doesn't work though so I'll leave #34 for reference for the time being.

hanoii’s picture

jurgenhaas’s picture

Thanks @hanoii for coordinating this with the what's now a duplicate issue #2915993: Adjust render_new_comments_node_links to fix issues. I will give this patch a try and report back on the success.

hanoii’s picture

Issue summary: View changes
jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

@hanoii I've tested the patch from #34 with Drupal 8.5.2 and can confirm that it is working just fine. Giving it a RTBC.

andypost’s picture

Status: Reviewed & tested by the community » Needs work

It still needs tests

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nevergone’s picture

patch #31 re-rolled for 8.6.x (da56eaa0ab40)

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nevergone’s picture

Version: 8.8.x-dev » 8.7.x-dev
Issue summary: View changes
Status: Needs work » Active
andypost’s picture

Status: Active » Needs work

for tests

nevergone’s picture

Status: Needs work » Active

@andypost
(Sorry, my english is bad.)
So, Drupal 8 use two comment types by default: "Default comments" (comment) and "Comment_forum" (comment_forum), and use two comment field with the same name.
Article content type use "comment" comment type and forum topic content type use "comment_forum" comment type.
Therefore, if there are articles and forum posts in the tracker activity page, none of the solutions work.

See "Steps to reproduce" from the issue.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

nevergone’s picture

Issue tags: -JavaScript +JavaScript
FileSize
5.66 KB
1.71 KB

Drupal 8.8.x rerolled patch.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

quietone’s picture

Status: Active » Postponed

This extension is deprecated and scheduled for removal in Drupal 11.

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to the contributed extension once the Drupal 11 branch is open.

Version: 9.5.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. 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 » Active
Related issues: +#366511: Decouple Comment module from Tracker