Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Whatever dolt wrote the patch for issue #1044322 did not account for the fact that {history} is clobbered by cron and entries older than NODE_NEW_LIMIT are removed. This causes node_last_viewed() to return 0, which our previously mentioned myopic patcher assumed meant that the node had never been viewed; no, it means the node doesn't exist in {history} (potentially anymore). So, we have to also check node_last_changed() to see if it's older than NODE_NEW_LIMIT, and if so, we don't mark the node as unread.
The patch is attached. It's tested, and fixes the issue.
Comment | File | Size | Author |
---|---|---|---|
#6 | stupid_idiot_did_not_read_api_carefully_updated.patch | 830 bytes | rcurtin |
stupid_idiot_did_not_read_api_carefully.patch | 858 bytes | rcurtin | |
Comments
Comment #1
rcurtin CreditAttribution: rcurtin commentedSorry, mistype. The referenced issue is #1044322: A new topic with no comments does not show new post icon (now you get a nice link).
Comment #2
MichelleLOL! I was about to take you to task for being so nasty to someone who was nice enough to write a patch... Maybe I should still do that, actually. Not nice to be so nasty to the poor fellow who made a simple mistake. :)
Thanks for the update. Having company for a week (my office is the guest room) has really put me behind and I'm not in a position to apply this right now since my dev environment is messy. Will get to it ASAP, though.
Michelle
Comment #3
mcdruidThanks rcurtin - could you check that this patch really is necessary against the latest 6.x-2.x-dev though please?
It's taken me a little while to work out what's going on; I think Michelle has committed your patch from #1044322 but that it didn't include the stuff you're now removing in your new patch.
I could be wrong, but I don't actually think we need to worry about this as the code you want to remove is not actually there in the branch.
Let me know if I've got the wrong end of the stick.
Comment #4
MichelleYeah, I never did anything on this issue. I pretty much missed the entire month of May due to being ill and never really got back into AF before switching gears to Artesian.
Michelle
Comment #5
rcurtin CreditAttribution: rcurtin commentedSorry for the delay -- life happened (I hate that!). This is still necessary against the latest 6.x-2.x-dev; or, that is what I am experiencing, having upgraded to a clean 6.x-2.x-dev and seeing the same issues, with old posts being marked new.
Comment #6
rcurtin CreditAttribution: rcurtin commentedAh, the old patch doesn't work anymore. I've updated it for great justice.
Comment #7
mcdruid@rcurtin - no problem, I've had quite a lot of life happening recently too!
I'm still a bit confused about what's going on here. AFAICS your (updated) patch is trying to remove lines which are not there in the 6.x-2.x branch:
patch:
6.x-2.x branch / current dev release:
So unless I'm missing something, I don't see that your patch is necessary, nor will it actually apply to the branch or the dev release (dated 2011-Aug-02 at the moment).
Comment #8
rcurtin CreditAttribution: rcurtin commentedThe patch was created backwards by accident, but read it again with the +s and -s and vice versa. patch will happily take this and apply it correctly, though (try it if you like).
Here is a further description of the bug and why the patch is necessary. At some point in printing out all the topics (or forums), we must decide if each one has anything new in it or not, so we know which icon to use (no new posts / new posts). Before #1044322: A new topic with no comments does not show new post icon was fixed, the code simply checked to see if there were new comments or nodecomments, based on which the forum itself was using. However, the code did not check to see if the original forum post (not the comments) had been viewed, and #1044322: A new topic with no comments does not show new post icon fixed that.
Now, this introduced another issue. The node_last_viewed($nid) call will return 0 if there is no record in {history} of the node being viewed. {history} is clobbered by cron regularly, removing all history entries older than NODE_NEW_LIMIT. As a result, what happens is that posts older than NODE_NEW_LIMIT are marked as new (again because node_last_viewed($nid) return 0 since the record of its viewing in {history} has been removed).
So, in the end, the best decision is to check if the node was modified before NODE_NEW_LIMIT (meaning that a view could possibly have been deleted from {history}), and if it was modified before then, we say it was already viewed. Yes, it is possible that we could mark a very old post that a user has never seen as viewed, but, this is the price paid to keep {history} small. There is not a good, space-efficient solution to keeping completely accurate node viewing data, and inside of the current framework, this is the best we can do. Even if we did add another table to keep track of forum history losslessly, now we have another big table (because it's not going to be small).
Is this enough information or should I add more to the dissertation here? You can try this yourself but you need a forum with posts older than NODE_NEW_LIMIT and then you need to run cron to remove old things from {history}.
Comment #9
mcdruidrcurtin, thanks for your patch and your excellent dissertation.
However, I can only give you an A- because of the backwards patch :-)
Committed to 6.x-2.x branch.
Comment #11
FiNeX CreditAttribution: FiNeX commentedI want to report that the patch is not available on http://drupal.org/node/438698 (current -dev version) and in the current git repo.
Comment #12
FiNeX CreditAttribution: FiNeX commentedComment #13
mcdruidare you sure about that? I've just checked advanced_forum-6.x-2.x-dev which is currently dated Aug 12th 2011, and the git repo, and I believe the changes are there in both.