Hello everyone,

I am experiencing an issue where one of my categories in the forum always has the "1 New" message notice on the forum. It does not go away by clicking mark all messages as read. I even erased a couple of latest messages but also did not work.

You can see what I mean here:

http://www.cancerconnections.com.au/forum

Any idea on how to fix this?

Any help would be very welcome.

CommentFileSizeAuthor
#5 db screenshot.jpg89.85 KBtotocol
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Michelle’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Is the "1 new" in the topics column or the posts column? If it's on the topics, does it go away if you disable AF?

Michelle

totocol’s picture

Hi Michelle,

Thanks for the quick reply.

it is in the "posts column" I disabled AF and the "1 new" was gone. I enabled AF again and the "1 new" was back. I ran update.php on both cases. Any other idea on how I could fix this?

Thanks again,

Raul

Michelle’s picture

The post count isn't in core so that will always go away if you disable AF.

The query that gets this is cached so possibly there's an issue there. Try clearing your cache (under performance).

If that doesn't do it, put this into a page with the php filter enabled:

   $uid=1;
    $vid = variable_get('forum_nav_vocabulary', '');
    $sql = "SELECT c.cid, tn.tid
            FROM {comments} c
            INNER JOIN {term_node} tn ON c.nid = tn.nid
            INNER JOIN {term_data} td ON td.tid = tn.tid AND td.vid = %d
            LEFT JOIN {history} h ON c.nid = h.nid AND h.uid = %d
            WHERE c.status = 0 AND c.timestamp > %d AND (c.timestamp > h.timestamp OR h.timestamp IS NULL)
            GROUP BY tn.tid";
    $sql = db_rewrite_sql($sql, 'c', 'cid');
    $result = db_query($sql, $vid, $uid, NODE_NEW_LIMIT);
    while ($row = db_fetch_array($result)) {
        print $row['cid'] . '<br>';
    }

Change the $uid=1; to the UID of the user with the problem. That should spit out the comment ID of the problem comment. If you look that comment up in the database maybe it will give you some idea of why it's stuck.

Michelle

totocol’s picture

Hi Michelle,

Clearing cache did not help. The "1 new" is staying for all users.

I will try the PHP code and report back.

Thanks again

totocol’s picture

Status: Postponed (maintainer needs more info) » Fixed
FileSize
89.85 KB

Hi Michelle,

I followed your instructions and I got the cid of the problem comment. I did not look different to the others so that I could get a clue about what it was. I have attached a screenshot.

I have decided to delete that comment all together and the "1 new" is gone.

Thanks a lot again for your quick reply and effective solution.

Raul

Michelle’s picture

Weird, I don't know what was special about the comment. You didn't say which one it was so it's hard to tell anything from your screenshot. All I can think of is the timestamp maybe got goofy somehow.

Michelle

totocol’s picture

Oh, sorry. It was comment 916. And yes, weird. There isn't anything in particular to point an issue with the comment.

Thanks a lot anyway. Great to have such a great support from one of my favourites Drupal contributors.

Raul

Michelle’s picture

Weird... It comes to March 17, 2009 so it's not like it was in the future or something odd. Leprechauns, maybe? LOL! Well, glad it's fixed and hopefully it won't happen again.

Michelle

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Jaypan’s picture

Status: Closed (fixed) » Active

I've had this same issue come up with the Silver Bells theme (if that makes any difference). Clearing the cache didn't do anything.

What I'm pretty sure happened is that a user either edited or deleted a comment, meaning that the thread had been updated. The problem was that clicking the '1 new' link didn't show which thread had been updated, so there was no way to know which thread to click on.

As a stopgap, I altered the script above to output links to the unread threads, created a page with that scirpt, and gave my users a link to that page so that they could click on links. The script now looks like this:

global $user;
$uid=$user->uid;
    $vid = variable_get('forum_nav_vocabulary', '');
    $sql = "SELECT c.cid, c.nid, tn.tid
            FROM {comments} c
            INNER JOIN {term_node} tn ON c.nid = tn.nid
            INNER JOIN {term_data} td ON td.tid = tn.tid AND td.vid = %d
            LEFT JOIN {history} h ON c.nid = h.nid AND h.uid = %d
            WHERE c.status = 0 AND c.timestamp > %d AND (c.timestamp > h.timestamp OR h.timestamp IS NULL)
            GROUP BY tn.tid";
    $sql = db_rewrite_sql($sql, 'c', 'cid');
    $result = db_query($sql, $vid, $uid, NODE_NEW_LIMIT);
    while ($row = db_fetch_array($result)) {
        print l('link', 'node/' . $row['nid']) . '<br>';
    }

However, this is only a stop-gap solution and doesn't actually fix the problem. I'm in the middle of a couple big projects right now and don't have time to try to track down the issue, but when I do, I'll see if I can figure out how to fix it.

Michelle’s picture

Status: Active » Postponed (maintainer needs more info)

Did you ever look at this anymore?

Jaypan’s picture

No! it still happens sometimes. I have no idea what the instigator is. I ended up creating a 'mark all forums read' button for my users, and they are able to clear the message using this. But I have no idea what the original issue was.

Michelle’s picture

What's the difference between your "mark all read" and AF's?

Jaypan’s picture

I never saw one on AF. My users were asking for one, so I built it in. Does it need to be enabled?

That said, I'm not sure I could use it anyways - my forum is quite customized, with various content types only be included as forum topics depending on various circumstances (for example, whether or not they have any comments), so a generic mark all forums read button may not work for my site.

Michelle’s picture

Oooh... I just noticed you're on 1.x. I haven't looked at that in sooooo long I don't remember what's in it. Most of the good stuff is in 2.x. That's why I'm triaging the queue... Trying to move things along to get that off alpha so people start using it.

Not sure what to set this... I don't know if I can do anything else without more info but it's hard to provide info for something that happens just now and then. :( I guess will just leave it as is for now and see if anything new pops up.

Michelle

Jaypan’s picture

I'm on 2.x. The OP was probably on 1.x.

If I see the problem specifically for my user in the future, I'll not clear it and leave a post here. We can debug it together, or maybe I can give you access to look at it.

Michelle’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Styles » Code

I'm going to set this to 2.x, then, if you have the problem there. 1.x isn't getting much attention at all anymore and I'm pushing to get 2.x stable.

Michelle’s picture

Title: One forum category always showing a new message » Mark all read sometimes misses some
Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

I'm going to bump this up to 7 since it's been reported there as well. If this is ever figured out, it should be backported to 6.

Unfortunately, I still haven't the foggiest.

joelrichard’s picture

I'm going to jump in here as I have this problem occurring and I plan to identify the trouble tonight.

My version: 7.x-2.0 (not dev) datestamp 1332167738

First off, when I do use EITHER the "mark all forums read" (on the main forum page) or the "mark all topics read" (in an individual forum) the items that are remaining are often on the last one or two topics in a given forum. Example, I have four pages of topics, all the ones up and including most of page 4 are cleared. But in this case, the last two topics still show "View 1 new" and "view 71 new".

It's definitely inconsistent as it seems to work in some forums but not others.

More info as I track it down.

joelrichard’s picture

Let's see if I can make some sense of the query that is being used to select the topics that need to be marked read. Here's one that I came up with that seems to miss two nodes: (it's finding 61 of 63 nodes in the forum)

SELECT n.nid AS nid
FROM node n
INNER JOIN forum f ON n.vid = f.vid
INNER JOIN taxonomy_term_data t ON f.tid = t.tid
INNER JOIN node_comment_statistics ncs ON n.nid = ncs.nid
WHERE 
((n.changed > ##NODE_NEW_LIMIT## ) OR (ncs.last_comment_timestamp > ##NODE_NEW_LIMIT## )) AND 
(f.tid = 161) AND
(t.vid = 2);

If I understand correctly, NODE_NEW_LIMIT is calculated by default to be one month ago.

From what I can tell, this is only going to find those items that were modified or whose comments were added within the past month. Am I correct?

I think the correction here is to remove the check for n.changed and ncs.last_comment_timestamp. When I try this on my copy of the code, it correctly identifies 63 node to be marked as read.

I think this makes sense to me. What about you, Michelle?

Thanks!!
--Joel

Michelle’s picture

troky ported and is caring for the D7 branch. I haven't had my head in this in a long time. He's doing a great job with this so I'll leave it up to him. :)

Michelle

troky’s picture

Category: support » bug
Status: Active » Fixed

It's interesting that nobody saw NODE_NEW_LIMIT bug before... Thanks for tracking it down.
Fixed in 7.x-2.x-dev

Michelle’s picture

Just looked at that closer... Why would you need to mark read things older than the new limit? Things older than the new limit don't show as new anyway... I guess just be careful not to bloat the history table. I'm pretty fuzzy on this stuff since it's been so long but I'm at least somewhat sure that was the reason for adding that check.

Michelle

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.