Error Message when editing large number of topics

AI-generated summary

Error Message when editing large number of topics

@christian_01 encountered an error message when trying to edit a large number of topics (over 60) at once. The error message read “Sorry, an error has occurred.” @codinghorror explained that this is due to an expensive operation timing out.

@jomaxro suggested using the rails console for bulk editing and provided a link to the administrative bulk operations guide.

@christian_01 revealed that they have thousands of topics in a category and needed to delete them all. @jomaxro recommended using the rails console to bulk delete topics and provided a link to the guide on deleting all topics in a category.

@christian_01 successfully bulk removed all topics in the category but encountered an issue deleting the category itself due to a remaining topic count of 1. @simon explained that the destroy:topics task might not delete system-created topics or pinned topics, such as the category’s About topic.

@christian_01 confirmed that the issue was with the About topic. @simon suggested checking for unlisted topics or using the rails console to delete it.

@christian_01 ultimately managed to delete the whole category successfully using the rake destroy:categories command.

Does anyone know why I keep getting this error message when I try and edit more than about 60 topics at once.

‘‘Sorry, an error has occurred.’’

The only workaround is to edit a small number of topics at once - about 30.

It is a very expensive operation so it is timing out.

Thank you for the feedback, but is there a way to fix it?

Select less topics at once. I’d suggest keeping it to a about 50 per batch. If you need to bulk edit a very large number of topics, use of the rails console will be necessary. See Administrative Bulk Operations

I have thousands of topics in a category!

Then using the rails console is the best solution here. See the link above for bulk operations.

I can’t see an option to bulk delete all topics in a category?

The guide to delete all topics in a category is linked in the Destructive rake tasks section of the guide.

As noted in that guide, please be sure to take a backup before running any destructive tasks like these in case something doesn’t go well.

Right, I’m getting somewhere.

I have successfully bulk removed all topics in a category, but it’s not letting me delete the entire category now because it’s saying:

‘‘Can’t delete this category because topic count is 1.’’

As far as I can see, there are no topics.

Any ideas?

That’s odd. In that case, try deleting the category from the console. See Delete entire categories in the Bulk Operations topic for details.

A quick follow up @christian_01. In the future, please ask for help with what your real issue is - in this case deleting a category with topics in it - rather than what you’re trying to do to solve the issue.

From what I gather, your ultimate goal is deleting a category with lots of topics in it. Had we know that from the beginning, I could’ve pointed you directly to the guide on deleting categories with topics. Instead, we ended up answering a number of other questions, which only got you part way to your goal. Please see

The destroy:topics task won’t delete topics that were created by the system user. It will also not delete pinned topics. This means there is a good chance that the category’s About topic will not be deleted. If that’s the case, you can delete it manually.

Yes, that’s the issue I’m having. The last topic to delete is the ‘About’, which I’m struggling to delete.

It’s possible that the About topic was unlisted. If you are logged into the site with a staff account, you should be able to see unlisted topics. If for some reason you can’t find the topic, you will be able to get it from the rails console.

No, it’s listed okay. I select delete, but it doesn’t go.

It does have replies. Does that matter?

Can you try deleting the topic with your browser’s web inspector open on its ‘console’ tab? There may be an error message that lets us know what the problem is.

The other place to look is in your site’s error logs (Admin / Logs / Error Logs.) Deselect the ‘Debug’, ‘Info’, and ‘Warning’ checkboxes from the bottom left of the error logs page so that you’ll only see the errors in the log list.

It should be possible to delete a topic that has replies.

Thank you for your feedback @simon.

I managed to delete the whole category successfully using ‘‘rake destroy:categories[…]’’