# Topic keeps getting deleted

**URL:** <https://meta.discourse.org/t/topic-keeps-getting-deleted/128013>\
**Category:** Bug\
**Created:** [September 9, 2019, 10:35am UTC](https://meta.discourse.org/t/topic-keeps-getting-deleted/128013 "2019-09-09T10:35:47Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)\
**Post date:** [November 12, 2019, 5:09pm UTC](https://meta.discourse.org/t/topic-keeps-getting-deleted/128013/19 "2019-11-12T17:09:10Z")

</div>

Here’s what I came up with:

1. User creates topic
2. User deletes topic post, scheduling deletion (I changed the `delete_removed_posts_after` site setting to `1`)
3. Topic is deleted after specified time
4. Staff undeletes topic and reverts to the original version of the post (only restoring will bring the post back with the “topic withdrawn by author, will be automatically deleted in 1 hour unless flagged” message)
5. Topic will re-delete after some time

**What’s happening:** When a user deletes there own topic post, there is a property called `user_deleted` that gets set to `true`. There is a background job called `DestroyOldDeletionStubs` that runs every 30 minutes. This job runs the `PostDestroyer.destroy_stubs` function which will search the database and delete any posts that have `user_deleted` set to `true` along with an expired “deletion timer.”

**The problem:** When staff restores the post, `user_deleted` never gets set to `false`, so the next time `DestroyOldDeletionStubs` runs, the post will be re-deleted.

**The solution:** I’m pretty sure we will need to add some logic to the `staff_recovered` function that will set `user_deleted` to `false` (`user_recovered` already does this) See [discourse/lib/post\_destroyer.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/lib/post_destroyer.rb)

**The quick fix:** Restore the topic post and get its post ID, then go to your rails console and run:

```ruby
Post.find_by_id(POST_ID).update(user_deleted: false)

```

The post ID can be found easily by appending `.json` to the end of a topic URL. So using this topic as an example: [https://meta.discourse.org/t/topic-keeps-getting-deleted/128013.json](https://meta.discourse.org/t/topic-keeps-getting-deleted/128013.json). The topic post ID is `632362`.

---

_[View the full topic](https://meta.discourse.org/t/topic-keeps-getting-deleted/128013)._
