Note that to test this properly you need a database with some orphaned posts. Follow these steps with a 2.3 instance without this fix applied.
1. Revert MDL-31664 .
2. Create a forum.
3. Create a discussion (post A) as a user.
4. Post a reply (post B) as another user.
5. Post another reply (post C) to Post B.
6. Post a separate reply (post D) to Post A.
7. Delete Post B.
8. Verify that Post C and Post D are still in the database.
Now apply this fix to upgrade mod/forum. Run the upgrade. Post C should be deleted from the database. Posts A and D should still be there.