I'm currently working on the feature that deletes all posts made by a specific user and I just realised the amount of work involved in doing that. Jesus! It's not just a matter of deleting all posts made by him from the posts table.
If a post is in the "middle of a topic", e.g. not the first post and not the last post, we can just delete it.
If a post is the first post, we have to delete all posts in that topic and the topic itself. We then update lastpost/lastposter for the forum in which the topic was placed (if it was the "newest" topic that is).
If a post is the last post, we have to delete the post and then update lastpost/lastposter for the topic. We might also have to update lastpost/lastposter for the forum in which the topic is placed.
Then, finally, we have to strip all those posts out of the search index.
What have I gotten myself into! :)
Edit: Oh, I forgot. We also have to decrement the post count for the topic :)
Edit2: It's done. I moved some code from delete.php into functions and called them instead of doing it all over again.
"Programming is like sex: one mistake and you have to support it for the rest of your life."