Last week we were asked to disable the "threads" in the comments and display them as a plain list in one of our projects, so checking in the Comment field settings we found an option which says:
"Threading: Show comment replies in a threaded list."
Which basically display the comments as a threaded instead of a list of comments. This option is marked on by default, so it seemed that it was just a matter of unchecking this option, but there was a problem with this, that setting did display the comments as a plain list, but in the code they were still being saved as a thread.
The main problem with this is if a comment is deleted and it has replies (even if the option of the thread is unchecked) all the replies are going to be deleted as well.
This is not a new problem there is an 11 year old issue and it seems that this has been happening since Drupal 4. The way to fix this so far was by using a contrib module called: Flat Comments The problem is that this module hasn't been ported to D8 yet.
We decided to fix that and port the module to help others with this problem. You can check the code here: https://github.com/agaric/flat_comments and we are in contact with the module's maintainer to create the D8 branch in drupal.org soon.
Expecting that this can help someone else.
Comments
2017 July 01
ajayg
Not really
Are you sure this is really a problem (and not what is says in comments or messages).
I have been using this option (Drupal core without contributed module) in production with non threaded comments for 11 years (since drupal 5x) and it does NOT actually delete the comment which came after a comment was deleted. And this has been tested , in production with over million comments and at least hundred thousand nodes and been tested atleast few thousand times.
I agree the message it shows feels scary, but somehow it does not work that way.
One important thing to note . We enable the non threaded comments immediately after the node type created. So any comment is actually flat from the moment it is created. I think what is happening is every subsequent comments is a new thread internally and that is why a reply to it is NOT lost.
Now there is a use case where it was threaded comment initially and then moved to non threaded and I don't know what happens then . But I would say it is an edge case as you either keep comments threaded for a node type or don't.
2017 July 11
David Valdez
Yes this is still a problem
Hi ajayg.
I wrote a small test proving that this is still happening.
The test basically set the default_mode as COMMENT_MODE_FLAT, create some comments and after that delete the first one and try to check that the rest are still there and as expected it fails.
I left the test here if you want to do your own tests:
https://gist.github.com/gnuget/b5064ccb45dc5e481a28946785391777
You need to place this field at:
and you can execute the rest using this command (it requires the simple test module):
If you run the test using the UI you can see the output and see that all the replies were deleted as well even with the COMMENT_MODE_FLAT option.
Thanks for your comment.
2017 July 30
ajayg
I am really baffled
I just now tested this on my D7 test site using normal drupal UI. I tried deleting first comment on a node and a couple of comments in between. For all cases it only deleted the comment I deleted explicitly. The node has all flat comments.
As I said I am using this feature from D5 and it behaved exactly same all these years and literally tried thousands of times as part of day today moderating in production.
Please note all my tests were manual using druapl UI, NOT automated.
2017 July 30
ajayg
Few more updates
I do see the message " Comments and all its replies deleted" After I delete a comment. But for some reason it does not delete comments which came after it. Because it is a flat comment structure I do not have any links on each comment to reply it. So I am thinking somehow it is treating each new comment as a new thread.
2017 August 30
mlncn
"Because it is a flat comment
"Because it is a flat comment structure I do not have any links on each comment to reply it." — you may have a theme that doesn't display these links or may have configured them not to show, because they are not necessary for flat comments, but it is possible for the individual reply links to show on flat comments, and if they do, that is when this problem arises.
Add new comment