DNNCommunity / DNN.Forum

DNN.Forum
9 stars 7 forks source link

PostConnector.SubmitExternalPost (10 args) crash #9

Closed roman-yagodin closed 7 years ago

roman-yagodin commented 7 years ago
InnerMessage:Value cannot be null. Parameter name: collection

InnerStackTrace:

   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at DotNetNuke.Modules.Forum.PostConnector.PostToDatabase(Int32 TabID, Int32 ModuleID, Configuration objConfig, Int32 PortalID, ForumUserInfo objForumUser, String PostSubject, String PostBody, ForumInfo objForum, Int32 ParentPostID, Int32 PostID, Boolean IsPinned, Boolean IsClosed, Boolean ReplyNotify, ThreadStatus Status, String lstAttachmentFileIDs, String RemoteAddress, Int32 PollID, Int32 ThreadID, PostAction objAction, Boolean IsModerated, List`1 Terms)
   at DotNetNuke.Modules.Forum.PostConnector.PostingValidation(Int32 TabID, Int32 ModuleID, Int32 PortalID, Int32 UserID, String PostSubject, String PostBody, Int32 ForumID, Int32 ParentPostID, Int32 PostID, Boolean IsPinned, Boolean IsClosed, Boolean ReplyNotify, ThreadStatus Status, String lstAttachmentFileIDs, String RemoteAddress, Int32 PollID, Boolean IsQuote, String Provider, Int32 ThreadID, List`1 Terms)
   at DotNetNuke.Modules.Forum.PostConnector.SubmitExternalPost(Int32 TabID, Int32 ModuleID, Int32 PortalID, Int32 UserID, String PostSubject, String PostBody, Int32 ForumID, Int32 ParentPostID, String Attachments, String Provider)

Looks like this overload should not pass Nothing instead of List(Of DotNetNuke.Entities.Content.Taxonomy.Term) to PostValidation() method:

Public Function SubmitExternalPost(ByVal TabID As Integer, ByVal ModuleID As Integer, ByVal PortalID As Integer, ByVal UserID As Integer, ByVal PostSubject As String, ByVal PostBody As String, ByVal ForumID As Integer, ByVal ParentPostID As Integer, ByVal Attachments As String, ByVal Provider As String) As PostMessage
            Return PostingValidation(TabID, ModuleID, PortalID, UserID, PostSubject, PostBody, ForumID, ParentPostID, -1, False, False, False, Forum.ThreadStatus.NotSet, Attachments, "0.0.0.0", -1, False, Provider, -1, Nothing)
End Function

Or there should be some defensive coding in PostToDatabase() around AddRange():

objThread.ModuleID = ModuleID
objThread.TabID = TabID
objThread.SitemapInclude = objForum.EnableSitemap
objThread.Terms.Clear()
objThread.Terms.AddRange(Terms)
juvander commented 7 years ago

This method seems to be marked as out of date already some time ago. Can you use the other SubmitExternalPost and add the Terms through that?

Added just in case a check that Terms have a value for the future before trying to add them.

roman-yagodin commented 7 years ago

Other SubmitExternalPost() overload (12 args) works fine, thanks.

juvander commented 7 years ago

Ok, closing this