FriendsOfSymfony / FOSCommentBundle

Threaded comments for Symfony
http://friendsofsymfony.github.com/
MIT License
462 stars 230 forks source link

Thread ancestors not updated when using delete cascades #726

Open Martin1982 opened 3 years ago

Martin1982 commented 3 years ago

I'm working on a feature where users can remove their account and data (in accordance with GDPR regulations). For this when an author deletes their account their comments are removed with an onDelete="CASCADE" on this column.

In general this works great, until someone has a reply in a comment tree, the ancestor column saves the id's with a slash-delimiter. Once a page with a thread is visited and one of these id's doesn't exist anymore an error is thrown;

Notice: Undefined offset: 3

In the file vendor/friendsofsymfony/comment-bundle/Model/Tree.php (line 62)

It would be nice to have an exception thrown here which can be caught. And it would even be greater if the slash delimited ancestors value can be regenerated upon this exception when it's caught.