I've had this issue in Drupal 7 beta 3 as well as the latest 7.x-dev (the 7.x dev was tested with a base install with the base theme with no additional configuration. Additionally, I tested this in a base install of Ubuntu 10.04 with only the minimal configuration needed to get Drupal running).
The issue is simple: the new comment marker does not work.
When a second user comments on a node, the first user sees "1 new comment". However the node page itself does not display the "new" flag and the "#new" bookmark in the URL does not bring the user down to the new comment.
Please let me know if any other information will be helpful.
Comments
Comment #1
neopoet commentedThis is still present in RC1
Comment #2
montesq commentedOK I reproduce it on my side with 7.x-dev
Indeed, when I read a node, I can't see which comments are new since my previous visit... (regardless the theme...)
Comment #3
neopoet commentedAnd in RC2 as well...
I've tested this on a clean environment with default settings. I'm certain that this issue is systematic.
Comment #4
montesq commented7.x-dev is the current development version (=the most recent/up to date). So we need to put this in the version field if the issue still occurs on the cvs branch
Comment #5
montesq commentedWhen I change (in the file comment.module, CommentController::attachLoad()) the line :
$comment->new = node_mark($comment->nid, $comment->changed);to
$comment->new = 1;then, all the comments are marked as "new". Quite a good news, isn't it?
After doing some quick tests with the node_mark function, I don't find any issue, so I'm wondering if $comment->nid and $comment->changed are correctly set... I'll check this evening. Until this, if someone has a piece of advice...
Comment #6
peterpoe commentedWow. There are multiple layers of broken here. I wonder if/how this ever worked in d6? Maybe themes used to take care of the "new" tag?
Broken #1:
node_mark will only return MARK_NEW if the node has never been viewed. But this is not what we want for comments. For comments, the logic, I think, should be:
a) If a node has already been viewed at least once by the user, and the creation time of the comment is higher than the time the node was last viewed, mark the comment as NEW
b) If a node has already been viewed at least once by the user, and the last changed time of the comment is higher than the time the node was last viewed, mark the comment as UPDATED.
This can be solved introducing an entirely new function, but...
Broken #2:
The problem is, that once we get to the comment viewing logic, the last viewed timestamp of the node has already been updated (this happens in node_show), so the system will always think that the user has already viewed the node after the comment was created/updated. In d6, the timestamp used to be updated after the node output was built, which makes much more sense to me.
The proposed solution is to move the updating of the last viewed timestamp at the end of node_show. But I don't know if this could cause problems elsewhere (like, no last viewed timestamp in db when a node has never been viewed before? or worse?).
Broken #3:
This is just a presentation issue: in template_preprocess_comment, new comments markers are not passed through theme_mark. So, there is no themeing and no difference between MARK_NEW and MARK_UPDATED: the output always shows just a plain 'new'.
The patch here: http://pastebin.com/NB8CP3hQ attempts to solve all three issues. I would attach it in the issue but I keep getting validation errors for any file that I try to upload. Maybe has something to do with the problems on drupal.org today?
Note: I changed the component to node.module to stress the importance of this issue. It's not so much as being critical, but the problem in node_show makes so that the 'history' table is updated in a wrong way, that affects not only comments but every system that relies on it.
Comment #7
bleen commentedComment #8
peterpoe commentedHere's the patch.
About tests: I don't have much experience with tests but I can try. Just need an advice: should I write a new test case or just add to testCommentInterface()?
Comment #9
peterpoe commentedComment #10
neopoet commentedFYI. We've been using the patch from #9 on our live site with no apparent ill effects. Thanks to all who contributed to a solution.
Comment #11
catchPatch looks good on first glance, however I don't think we need the static cache in there, since node_last_viewed() already has one.
Also this could do with tests so it doesn't regress again.
Comment #12
peterpoe commentedRerolled, removed static cache in commen_mark, added test written by drunken monkey here: #6371: All comments marked as read when viewing any page.
Comment #14
neopoet commentedThe patch in #12 (besides failing testing) creates a problem -- when you view a page with a new comment posted, _all_ comments are marked new. I've reversed it and reapplied #9, which still works.
Comment #15
peterpoe commentedCorrected wrong variable name in comment_mark.
Comment #16
neopoet commentedPeter,
Thanks for all your help.
Unfortunately this patch still has the issue. For example, if you go to a comment page that says "3 new comments", all 17 (for example) are marked "new" and are highlighted.
Andrew
Comment #17
marcingy commentedThe above patch was checking against nid and not the timestamp as the patch in #9 was this should resolve that issue.
Comment #18
neopoet commentedLooks like it works. I'll let you know if any problems come up. Guess once this is past tests we can commit it.
Comment #20
neopoet commentedI think this meets the definition of a critical issue -- this is really a major regression from Drupal 6. The comments system is extremely actively used, and the "new" marker is a significant usability feature. It is important to have this right for the Drupal 7 release.
Comment #21
marcingy commentedThis is major at best.
Comment #22
marcingy commentedThis patch should hopefully work and pass the tests for new comments.
Comment #23
marcingy commentedComment #24
marcingy commentedMinor change to add a comment to explain why we work out timestamp the way we do.
Comment #25
marcingy commentedReroll as comment changes have hit head.
Comment #27
marcingy commentedRework comment creation to ensure we don't have permissions issue when creating with the admin user.
Comment #28
catchIs it possible to make this a positive assertion somehow? If we ever change this text the assertion will always pass even if it breaks.
Otherwise this looks good to me.
Comment #29
marcingy commentedThe only possible solution that code use a postive assertion is to check that we only have 1 li elements present (Read more link) alternative version of the patch with this approach attached. It leaves in the existing asserts and makes sure that the n links are correct - so 1 link which is read more.
Comment #31
marcingy commentedTest pass locally so not sure what the issue is here.
Comment #32
marcingy commented#29: 983632-comment-mark-7.patch queued for re-testing.
Comment #34
marcingy commentedTry as I might I can't get the tests to fail locally can someone else try running the tests on their localhost or server and see if they can get it to fail. And if that happens let me know what they are seeing when things do fail.
Comment #35
marcingy commented#29: 983632-comment-mark-7.patch queued for re-testing.
Comment #37
v.zhakov commentedsubscribe
Comment #38
snupy commentedsubscribe
Comment #39
steven jones commentedSubscribe.
Comment #40
sunA missing or not properly working new/updated marker is an extreme stretch of the major priority. Definitely not major.
I suspect that this is the only required change for this issue.
Powered by Dreditor.
Comment #41
catchThis is an obvious, site-visitor facing, regression from Drupal 6 and is causing duplicate reports in the issue queue such as http://drupal.org/node/6371#comment-4692102
Any site with a lot of comments and regular visitors (i.e. drupal.org or groups.drupal.org) is unusable without being able to see which comments are new or not. If Drupal.org or g.d.o upgraded to D7 without this bug being fixed it would be a serious pain in the arse, same for any other community site that is registered user + comment heavy. So I think it qualifies as major for those reasons.
I couldn't reproduce the test bot fail locally, I also agree with sun that the hunk he posted looks like the only necessary bug fix here, previous patches are introducing a markup change which we should try to avoid for D7 if at all possible now anyway.
So re-rolled with just the tests and that hunk, all comment tests pass locally for me, the only other change I made was tidying some of the code comments in the tests.
Comment #42
marcingy commentedHappy to rtbc this.
Comment #43
webchickAwesome! Thanks a lot for the fix and the tests! What a nasty bug. :\
Committed and pushed to 8.x and 7.x. Thanks!
Comment #44
nevergonePatch is good work, but #new marker is lost, if I use comment pager.
http://drupal.org/node/1215574
Comment #46
pillarsdotnet commentedNote that the tests added by this issue wrongly assume that the "Read more" link will always be present for teaser nodes.
This is blocking: #823380: Read More link is always visible on teaser.
See also: #1300568: Fix tests that wrongly assume all teasers have a Read more link
Comment #47
catchLet's fix it in those issues rather than re-opening this one that was done three months ago then.
Comment #48
pillarsdotnet commentedThe problem is, I don't understand the tests well enough to rewrite them. Presumably the authors who contributed to this issue would have that understanding.
Comment #49
sunThat's fine. People know of the other issue by now. This bug here has been fixed, case closed.
Comment #50
xjm