Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
[Bug] Duplication of discussion during editing
I think I have found a bug when editing a discussion.
Everytime I edit the first comment of a discussion, and force a validation error (leaving the discussion topic, or the comments box empty) I get a warning and the same discussion form. But when I eliminate the validation error condition and save the changes, I get a new discussion with only one comment, instead of the original discussion being edited.
Moreover, if I force a second validation error, when editing a discussion I get the warning but the discussion form is transformed in a comment form, and if saved, it goes to the end of the original discussion as a normal comment.
I guess that some PostBack information is lost when a validation error happends in a discussion form.
Everytime I edit the first comment of a discussion, and force a validation error (leaving the discussion topic, or the comments box empty) I get a warning and the same discussion form. But when I eliminate the validation error condition and save the changes, I get a new discussion with only one comment, instead of the original discussion being edited.
Moreover, if I force a second validation error, when editing a discussion I get the warning but the discussion form is transformed in a comment form, and if saved, it goes to the end of the original discussion as a normal comment.
I guess that some PostBack information is lost when a validation error happends in a discussion form.
0
This discussion has been closed.
Comments
http://....../post.php?CommentID=....
After a validation warning the parameter dissapears and the link looks like:
http://....../post.php
Edit: (Forget about this comment, I was not yet understanding how the postback information was added to the form)
if ($this->PostBackAction == 'SaveDiscussion') { $this->Discussion->Clear(); $this->Discussion->GetPropertiesFromForm($this->Context);
The Clear() operation erases the FirstCommentID and AuthUserID information in the Discussion object, which is afterwards used to generate the PostBack information in the GetDiscussionForm method.
I have commented the line and it works fine. Is there any reason I'm missing to enforce the Clear() operation?
Other solution could be to change the GetDiscussionForm method to get the PostBack information from the Comment object instead:
// $this->PostBackParams->Set('CommentID', $Discussion->FirstCommentID); // $this->PostBackParams->Set('AuthUserID', $Discussion->AuthUserID); $this->PostBackParams->Set('CommentID', $Discussion->Comment->CommentID); $this->PostBackParams->Set('AuthUserID', $Discussion->Comment->AuthUserID);
BTW, in the GetCommentForm setting the CommentID postback parameter is skipped. I have tried it also here, commenting the line which sets the CommentID directly, and it works. I don't know where it is done.
What is the better solution? Skip the clearing or changing the setting of the PostBack parameters? I would say that the first, as more information about the discussion may be lost in the clearing which may be needed in a delegation.
I have tried on this forum, having a look at the html generated when the saving attempts fail, and it is working perfectly for both, editing discussions and comments. The Discussion and Comment IDs are not lost anymore.
Where may I have a look at the new code? I'm interested on what you did with that constructor.
And, of course, thanks!