Thoughts about separation of discussions and comments
/!\ Warning! Do not read this if you think that there is a hidden question inside of this posting or something like this. Sometimes I have to write my thoughts down to get them clear and that has been the case here...
I've not understood why there is this separation in Vanilla between discussions and comments. There is no need to make a difference between the first posting in the thread and all the others. So it was a design decision and it is one of the very few "features" of Vanilla that I dislike.
I'm no database expert, but I'd assume that this decision is bad for Vanillas perfomance, but that's just a feeling and I wouldn't even know how to proof that.
Well, that's just the preface and this shall be no complaint.
Somebody has asked about a "related-plugin" and I was thinking about how something like this could be achieved. My first thought was that searching only in the discussion and not in the comments would be senseless and so I would have to search in two tables which would make a ranking even harder. So you would have to build a keyword table which handles discussions and comments just the same.
I wasn't sure if I had talked about something like that in a discussion before and so I thought I'd go over the profile and browse my postings. Well, I could only browse my discussions or my comments. There again...
And so I thought how I could access all my discussions and comments (in theory).
DiscussionModel->GetWhere(User = myself), I could do that, but there is no
CommentModel->GetWhere! Darn, that's no way either. And if there would be a CommentModel->GetWhere, what if I would want to mix discussions and comments because I want to sort them any way? There might be a way to sort two big arrays in a more or less efficient way, but it couldn't be as good as a PostModel->GetWhere which does that job on the db side.
So what's left? A helper function I haven't found and I have to admit that I wouldn't know where to look? I have not seen any mix of comments and discussions except for the search results and there it is a union of two queries, so I don't think there is such a function. Having to drill down each and every discussion to get its comments would be performance horror if it is done by each user.
To me the best solution for this would be a view. Why I do not like it is that the permissions check has to be done by anyone who uses that view. I think permission checking must be part of the framework itself to make it a reliable tool and using your own views are an obstruction for that.
Very, very unsatisfying... :-|