Recent Content duplicates forum posts

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
4/9/2015 4:57:24 AM
Gravatar
Total Posts 128

Recent Content duplicates forum posts

Hi Joe

2.4.0.8 MSSQL

A forum post appears twice in the Recent Content feature.

Replicated in the demo site, see https://demo.mojoportal.com/recent

 

4/9/2015 11:21:06 AM
Gravatar
Total Posts 18439

Re: Recent Content duplicates forum posts

The recent content feature is built on the search index, and it is possible sometimes for duplicate items to be created in the search index even though we've done our best to try to prevent it from happening. I've added some notes about it to the document rebuilding the search index. At this point I don't really have any better ideas to prevent that from happening and don't have time to throw at that problem right now.

4/9/2015 2:44:32 PM
Gravatar
Total Posts 537
feet planted firmly on the ground

Re: Recent Content duplicates forum posts

OK - thanks -  we can certainly rebuild the search index, but that appears to remove all forum posts from Recent Content, though not from the search index (replicated on demo site - a different bug?). I logged this issue because it seems to happen much more lately, in fact every time with forum posts, so I wondered whether some new bug had been introduced. It doesn't happen so consistently with HTML Content features. And this makes the Recent Content feature look shonky when every forum item is there twice.

If we get a chance to look at the code around the forum posts, we'll report back. We recently wired some custom features into the search index, and came across (and resolved) exactly these issues, so I think we know how it works ?!

 

7/22/2015 12:05:19 PM
Gravatar
Total Posts 128

Re: Recent Content duplicates forum posts

This has been bugging me so much I've investigated further and found the cause. When a new forum post is saved it is indexed twice because first in EditPost.aspx.cs we do this in the handler:

if((thread.PostId == -1)||(userIsAllowedToUpdateThisPost))

{

thread.Post();

(which in turn leads to this.CreatePost(); which leads to OnContentChanged(e); > indexBuilder.ContentChangedHandler(sender, e); >

newID = DBIndexingQueue.Create(

this.siteId,

this.indexPath,

this.serializedItem,

this.itemKey,

this.removeOnly);

(and we see a row created in table [mp_IndexingQueue]

Then we continue through the handler to this

if(!notifyModeratorOnly)

{

thread.NotificationSent = true;

// produces duplicate indexing CF

thread.UpdatePost();

which leads to a second indexing. Commenting out the last line above prevents the duplication.

I think one of many possible fixes might be to a) remove this section from CreatePost()... (in ForumThread.cs)

if (result)

{

ContentChangedEventArgs e = new ContentChangedEventArgs();

OnContentChanged(e);

}

and b) take this line outside its condition so it always runs  ... (in EditPost.aspx.cs):

thread.UpdatePost();

This should ensure every new post gets indexed, but only once. But it's all quite complicated and I might have got this wrong!

7/22/2015 1:38:14 PM
Gravatar
Total Posts 128

Re: Recent Content duplicates forum posts

Sorry that was a bad solution, editing an existing post still led to duplicate indexing as updatepost() was still called twice during the save.

A solution that works in to add this method to ForumThread.cs

public bool UpdatePostWithoutIndexing()

{

bool result = false;

result = DBForums.ForumPostUpdate(

this.postID,

this.postSubject,

this.postMessage,

this.postSortOrder,

this.isApproved,

this.approvedBy,

this.approvedUtc,

this.notificationSent,

this.postModStatus);

return result;

}

and use this within the following bit of EditPost.aspx.cs:

if(!notifyModeratorOnly)

{

thread.NotificationSent = true;

// produces duplicate indexing CF

//thread.UpdatePost();

// use this instead

thread.UpdatePostWithoutIndexing();

}

This change really results in only one row in the table for each post, reply, or edit.

However multiple edits in quick succession can result in multiple rows of the same index item, so I wonder whether a better fix would be to change the sproc to insert a record only if that ItemKey doesn't already exist in [mp_IndexingQueue]?

Even then we can still end up with the same thread index more than once so should we also be removing the thread from the index before re-indexing each time? At this point I don't know enough about how it works and have run out of time! but the above really does fix the main bug that caused highly visible duplication in the index and the recent content feature.

7/24/2015 12:29:14 PM
Gravatar
Total Posts 18439

Re: Recent Content duplicates forum posts

I've just committed changes to the repo that should prevent the contentchanged from firing more than once during a post. Now oncontentchanged fires from the Post() not from CreatePost or UpdatePost.

Whether that will solve the duplicate item issue I don't know.

7/24/2015 12:54:32 PM
Gravatar
Total Posts 128

Re: Recent Content duplicates forum posts

Yes, this fixes the issue nicely, have a beer!

7/24/2015 1:04:47 PM
Gravatar
Total Posts 18439

Re: Recent Content duplicates forum posts

Thanks for the beer! Glad that solved it.

Cheers,

Joe

You must sign in to post in the forums. This thread is closed to new posts.