User deleted the "About" post for a category

A user deleted all their posts, one of which was the “about” post for a category. We restored the post and changed the ownership to the System account, however it still appears “deleted” to an Admin, and shows an error when a non-Admin visits the post:

The post in question (which errors): About the Music category - Music - KGLW.net Forum

The category: Music - KGLW.net Forum

Is there a way to fix this?

(Should all the category “about” posts be assigned to the System account to avoid this scenario?)

3 Likes

Hi,

Not sure if this would work but try to re-build the HTML of the post. You can do this by clicking on the 3 dots → Wrench → “Rebuild HTML”.

1 Like

It’s not completely clear how they could delete an About topic as they are meant to be undeletable. :thinking:

Can you go into a little more detail about how this came about? Did they create the category?

4 Likes

When you use the Delete all posts button at the user’s admin page, the about topic is deleted. (In other cases the ownership is transfered to @system)

You could create a new category and move all the topics to that one and delete the old category. But that is more a workaround than a fix.

That’s an unfortunate sidestep. :thinking:

Though I’ve just repro’d on my test site and undeleting it made it come straight back again, so I’m not sure what this particular issue is.

It is possible to swop the topic_id of the About topic to a new one using the Rails console, but the ‘new category switcheroo’ might be an easier option through the UI.

2 Likes

The problem occurs when you change the ownership to system before undeleting the post.

2 Likes

I may need a step-by-step to make sure we’re doing the same thing. It looks like the user was deleted rather than only the posts?

3 Likes

There are two problems that are particularly unfortunate in combination.

  1. When you use “delete all posts” at the user’s admin page, the “about the category” post is deleted. (But you can undelete it)

  2. When you have deleted posts where the author is also deleted, and you change the ownership before undeleting the post, you cannot undelete the post. (As a workaround you can delete the topic and undelete it. This undeletes the first post)

So when you:

  • create a test user and test category,
  • make the test user the owner of the “about the category” topic,
  • delete all their posts from the user’s admin page,
  • (optional) create another topic owned by the test user,
  • (optional) reply to both topics using a different user,
  • delete the test user,
  • change the ownership of the “about” topic (and the other topic),
  • try to undelete the posts,

you receive an error, because you cannot undelete the post. Side note: the replies in the topics are visible for other users, but they cannot see the first post.

The workaround for 2 does not work, because you are not allowed to delete “about” topics

6 Likes

Yes I believe the user did create the category.

“Rebuild HTML” doesn’t seem to have changed anything.

I suppose we could create a new category and do a switcheroo, however would that mean that users who’ve subscribed/muted/whatever the original category would need to re-do that with the new one?

I’m not scared of the Rails console, so if assigning a new topic_id is the more ‘correct’ way to structure things then I’m leaning towards doing that. But I’d appreciate some hand-holding with the specific commands to run; would it be something like Category.find(10).topic_id = 723 …?

On the other hand:

…perhaps this is a quicker way to solve? (Although I just see “Archive Topic” and not “Delete Topic” in the wrench-icon menu…)

I have not tested this as thoroughly as others here (thank you!!) but it seems to me the fix for the stated problem in the first post is fairly straightforward.

  • do not allow deletion of about topics on user admin (by site moderators/admins)

When the above is attempted, prevent it and display an informative error message. I am moving to bug because it is a bug that the about topics can be deleted in the above case.

I did just create a test user and used that to create a category, and then deleted the user from the user admin. It allowed me to delete the user directly even though it had a topic. The about topic authorship was given over to the system user! So at least that use case seems to be fairly safe in this regard.

I also tried the self deletion case (have to demote the user first in order to see the delete account button). Deleting that user also gave topic authorship to system. Also, I see that the default for delete user self max post count is set to 1, which means that by default it is not possible for a user to delete themselves if they have more than one topic. So we are safe here anyway.

Screenshot 2024-06-04 at 1.13.44 PM

And I tested deleting the user via user admin. Interestingly, as long as there was only the one about topic I did not get the post delete button. But after creating a second topic I did get the post delete button. Selecting it and typing in the long text to confirm then worked - I was able to delete the user’s posts including the about topic. Finally a repro! :wink:

And finally, I was also able to delete the about topic using bulk actions. Another repro! Oops, now see that I do not have repro of bulk actions deleting About topics. It just fails to do so silently.

Given the above, we can ignore the user deletion (via user admin and self-deletion) cases because the authorship is given to system.

1 Like

I also tried to move the about post to a different topic. It works and then a delete timer shows up but the topic is not deleted after x days. The timer just disappeares. So this works okay.

1 Like

Did you manage to resolve your situation @alxndr?

2 Likes

This may well prevent it from happening in the future.

That said, how should I recover from the situation now, where users see an error page when trying to read the “About” post for this category, even though the post is owned by the system user?

I have not tried anything yet; I was hoping for someone to chime in with either “yes that’s the correct command” or “no don’t do that it’ll ruin everything” first…

2 Likes

I believe this is the format I used when I tried it awhile back:

Category.where(id: CAT_ID).update(topic_id: NEW TOPIC_ID)

Though I’m also wondering if undeleting that original topic using the API could be a thing. :thinking:

@alxndr can you confirm you are self-hosting, not on our hosting? If you are on our hosting or switch to our hosting, you can reach out to our team for support and one of our tech associates will help you get this fixed up.

If I were in your position, I’d just create a new category and move all the topics into the new category. That seems the most straightforward.

If you decide to experiment with the rails console or the API you are in uncharted territory, so be sure you do a full backup of your site first in case you need to revert the change!

1 Like

Ha :slight_smile: You sound like you don’t trust my advice @tobiaseigen :slight_smile:

Using the API would be a safer option than the rails console, it’s just not clear if it would successfully undelete this particular topic due to the circumstances.


I wasn’t confident the API would work as trying similar in the UI was blocked, but I seem to have had some success (:partying_face:).

In this case, I used the endpoint to recover the post rather than recover the topic (which is what the undelete option in the post was trying to do):

/posts/POST_ID/recover

4 Likes

Yep, self-hosting.

1 Like

The “undelete this post” button appears to use this endpoint, however it returns a 403 error, with errorThrown blank, and textStatus: "error".

However are you saying that using that same route via an API, and not the web UX, worked?

From my test, the undelete button was trying to use the topic recover endpoint (/t/TOPIC_ID/recover) and was throwing the 403. But it seemed happy when I used the posts recover version instead.

Can you double-check to make sure?

2 Likes

Ah thanks for the clarification, you are correct.

I’m not clear on how to identify the individual Post’s ID; the Category ID is 10 and I think the Topic ID is 723?
Update: Aha, found it! There’s a data-post-id on the <article> DOM element…

I don’t see this endpoint on the API docs… should it be a PUT? with any data?
Update: yes a PUT, with no data — it worked! Thank you @JammyDodger !!

2 Likes