Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Discussion doesn't refresh when you post a new comment?
rockwaldo
New
Since updating to 2.1 I'm finding that we're having some weird behaviour regarding refreshing threads.
For example: You're in a thread and you post a new comment. The new comment appears without requerying the page as the next on the list. However, when you refresh the page or revisit the thread, you see that there were other posts added in between your new one that didn't show. Is that expected behaviour?
Older versions used to requery the thread once you added a new comment didn't they? So you can immediately see where your comment fits in with everyone else's?
0
Comments
@rockwaldo
2.0 had an option to autorefresh which is no longer available in 2.1
AfaIk, the only way to be sure there are no new comments is either refresh in the thread, or always start from the Discussion list page.
It isn't so much autorefresh, its at the actual point of posting that it is weird.
So for example I start a new thread. Post one thing and then stay on that page. A minute later I post a new post and it shows up immediately as the second post in that thread. However, I press refresh and now there appears a post in between that somebody else posted in the meantime. That cant be correct?
It doesn't need autorefresh or anything, just a re-query once it displays the post rather than injecting it in?
Incidentally, this is obviously more prevalent on fast moving threads. It's really showing up now on our E3 thread for example.
You might be interested in the discussion here: http://vanillaforums.org/discussion/25575/auto-refresh-in-2-1b2
The short answer is that the auto-refresh feature can't be cached effectively, so it got the axe in 2.1.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Is it auto-refresh though? If it only refreshes once a comment is posted then it doesn't matter how many people have the forum open in tabs.
Just to be clear, I'm not talking about the thread refreshing so that you can see new comments before you post. I'm talking about it just requerying the posts once you add one.
As it stands, you add a comment into a discussion and then you have to manually refresh the thread AGAIN to see if any comments appear before your new one. That cant be right.
Actually, that's what most forums do, when they use Ajax. That is, you post the comment, and your comment just gets appended to the end of current page. When you refresh the page, then other comments may appear before yours.
To prevent this, the only manageable way would be triggering a full page refresh upon posting a comment. Doing everything via Ajax would be a mess, as you would have to fetch all the comments for a discussions, find out if paging is required, render the pager, and so on.
My shop | About Me
You are right, it felt dirty but I made it!
http://vanillaforums.org/addon/discussionrefresh-plugin
It was far less work than expected but I did not care about pagers and minor issues. To my opinion having such an imperfect implementation is far better than the current lack of such a feature.
Now add an "infinite scroll pager" and you are ready to go.
My shop | About Me
I've already thought about that! If it wouldn't need js skills to accomplish that, I might have already started. But me and js - we are no friends...
@R_J Nice plugin. A couple suggestions:
$DiscussionID = $Args[0] + 0; $LastCommentID = $Args[1] + 0;
Instead, cast them as (int) and then throw an error if they aren't > 0.
$Comments = $CommentModel->Get($DiscussionID);
Try to find a way to be more discerning here. If you have a 700-page discussion, this is going to exhaust your server's memory.
I could easily get only Comments > LastCommentID, but I thought it would be better to skip any where clause so that db caching could work, but honestly I don't have any clue what might be better on high server load. So you recommend CommentModel::GetNew?
The caching is per-page, so I'd recommend getting the entire current page and next page or two if they exist already. Then parse out the ones <= LastCommentID.
So that will be faster (because it is cached)
than this
or that
Is that true?
Then I would use $('li#LastCommentID div.CommentInfo a.Permalink').attr('name') to get the "Item_X" for determining the page count that I have to query - noting that down here a) so that I do not forget it and b) you can correct me if I'm doing it wrong
Since I want to get all comments >LastDiscussionID, I guess I would have to look at the results of $Comments = CommentModel::Get($DiscussionID, $Limit, $Offset) and repeat that call (raising the offset) until the Discussion->LastCommentID is in the result.
I'll try that and if you could make sense of my monolog above, I'd be happy if you say something like "guess it would be better than simply using GetNew" or "you're completly wrong!"
Many thanks for your help! I'd really like to make that plugin as good as it can be, because I think it is an important feature for a lot of people.
What you'd want to do is grab each page separately. Doing a 3-page query won't already be cached; per-page is all that'll be in cache. Here's me grabbing the current page, then adding an additional page if my current page is full:
Disclaimer: Treat that like untested pseudo-code, I wrote it off the top of my head with some quick copy/paste. It could contain glaring errors.
@R_J just to be precise, there is no guarantee that any data will be cached by the database engine, whether you use a
where
clause or not. Any change to a table (like posting a new comment) invalidates the cache, and data is retrieved from the tables again (there is no "per page" cache, where "page" is intended as a number of rows to display on screen).Regarding how to run queries, usually fewer queries are better than more queries, therefore I would advise against running more than one.
Further reading
Extract
My shop | About Me
@businessdad I'm specifically referring to our caching implementation with memcached, not MySQL's cache. See
CommentModel->PageWhere()
. You will get negligibly worse performance on sites with no caching because of the multiple queries. On huge sites with caching, it could likely be the difference of whether your site stays online or not.where this code i inserte
please help.....
I tried this plugin but it does nothing. I'm not sure why there is a
in the code, because I cannot find an element with LastCommentID anywhere, which is why this returns a NULL.
Could that be the reason? Does anyone have a fix?
I hate that the page does not refresh when saving, posting or editing but I'm not a coder, so I can't fix it myself.
@marxkarl: you can start a question for an addon on the addon screen. The advantage is that the plugin author will be notified and other people with the same problem can find answers more easily.
Looking at the source of the page and the addon, I'd say you are right. Don't know when they changed that, but it seems LastCommentID is now set in definitions.
I would have to work over that plugin. Sorry, but by now it really seems to be broken!