Reptophile
2008-12-15T01:13:51Z
Hi,

I couldn't see this mentioned anywhere else, but it seems if there is a moved topic in a forum list, and the bad word list is also being used, then the site will error (silently if in release mode). This is because the first message is being checked for bad words, but it is coming from the moved topic ID (which would return a null) rather than the original topic.

This shows up when viewing the list of topics in a forum that has a moved topic in it.

To fix, I referenced the original topic to get the first message:

in the sproc yaf_topic_list, change

FirstMessage = (SELECT TOP 1 CAST([Message] as nvarchar(1000)) FROM [dbo].[yaf_Message] mes2 where mes2.TopicID = c.TopicID AND mes2.Position = 0)

to

FirstMessage = (SELECT TOP 1 CAST([Message] as nvarchar(1000)) FROM [dbo].[yaf_Message] mes2 where mes2.TopicID = IsNull(c.TopicMovedID,c.TopicID) AND mes2.Position = 0)

Regards,

Reptophile

EDIT: same applies to the sproc yaf_topic_active, will error when searching for active topics if the above conditions are true.

Sponsor
Broads
  •  Broads
  • 51.8% (Neutral)
  • YAF Forumling
2008-12-16T02:14:04Z
To add to the previous post, this same issue is also apparent when viewing active topics.

I have had to modify the SP yaf_topic_active as follows


select
		c.ForumID,
		c.TopicID,
		c.Posted,
		LinkTopicID = IsNull(c.TopicMovedID,c.TopicID),
		Subject = c.Topic,
		c.UserID,
		Starter = IsNull(c.UserName,b.Name),
		NumPostsDeleted = (SELECT COUNT(1) FROM [dbo].[yaf_Message] mes WHERE mes.TopicID = isnull(c.TopicMovedId,c.TopicID) AND mes.IsDeleted = 1 AND mes.IsApproved = 1 AND ((@UserID IS NOT NULL AND mes.UserID = @UserID) OR (@UserID IS NULL)) ),
		Replies = (select count(1) from [dbo].[yaf_Message] x where x.TopicID=isnull(c.TopicMovedId,c.TopicID) and (x.Flags & 8)=0) - 1,
		Views = c.Views,
		LastPosted = c.LastPosted,
		LastUserID = c.LastUserID,
		LastUserName = IsNull(c.LastUserName,(select Name from [dbo].[yaf_User] x where x.UserID=c.LastUserID)),
		LastMessageID = c.LastMessageID,
		LastTopicID = c.TopicID,
		TopicFlags = c.Flags,
		c.Priority,
		c.PollID,
		ForumName = d.Name,
		c.TopicMovedID,
		ForumFlags = d.Flags,
		FirstMessage = (SELECT TOP 1 CAST([Message] as nvarchar(1000)) FROM [dbo].[yaf_Message] mes2 where mes2.TopicID = IsNull(c.TopicMovedID,c.TopicID) AND mes2.Position = 0)
	from


Mek
  •  Mek
  • 100% (Exalted)
  • YAF Developer
2008-12-16T03:11:15Z
Included in SVN: 27/12/2008.

Merry Xmas.


UserPostedImage 

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved