Tag gets broken if the first topic to use it is deleted
A user, GSeven, reported an issue where tags created in a topic that is then deleted become unusable. The tags do not appear on the tag page, and attempting to recreate them results in a “no matches found” error. Falco suggested a workaround by undeleting the topic and removing the tag, which GSeven confirmed worked.
However, it was discovered that this issue only occurs when the tag is used in its first topic and then deleted. If the topic is undeleted and the tag is removed, the tag becomes usable again. Mittineague found that the tags still exist in the database but are not visible on the tag page.
A possible solution is to edit the topic title to remove the tag before deleting the topic, which keeps the tag available for use. A pull request was made to fix this issue, but it relied on an unreleased version of Active Record. Neil made a commit to fix the issue, including the case of tags that have never been used not showing up in some cases.
I’m still learning about discourse, i don’t know how many times i have installed and uninstalled in the hope of getting things correct?
right now, i’m having a problem with tags.
I’m a level 4 mod and created 2 tags ‘oxford’ and ‘cambridge’ in two separate posts, then i deleted the posts, but now i can’t add those two tags to any further posts.
I can create and add a tag called ‘oxfor’ or ‘oxfordy’ but ‘oxford’ comes up with ‘no matches found’.
Oxford and Cambridge are not on the tag page, it is empty.
I have no idea what has gone wrong, do i need to clear out a cache somewhere or something?
I have undeleted the topics and deleted the tags from them. The tags now show up and can be added to new posts.
It appears to happen only if the tag is used and deleted in it’s first topic, if you have previous topics with the tag, it’s safe to delete the topic and the tag is still useable.
why deleting topics is not getting logged though i don’t know.
Sorry, I was primarily curious about the logging of the deleted topic. If the topic is 2 hours old, then deleting the topic should have been logged, but if the topic was less than the age of the ninja edit window… I wonder if that wouldn’t get logged.
One problem with this ?status=deleted workaround, is if you undelete a topic to reclaim the tag then delete the topic again, it sends you into a minus situation with your stats ‘topics created’ which in turn means the educate until posts 2 popup appears on the editor.
I haven’t looked into what code is involved, and I haven’t tested my hunch yet. but I’m guessing that if the tag is title edited away before the topic is deleted it could be reused.
EDIT
Yes, editing the topic title to remove a tag before deleting the topic keeps the created (and unused) tag available for use
Unfortunately, @falco’s fix relied on an unreleased version of Active Record. Also, there’s the case of tags that have never been used not showing up in some cases. I made a fix today for that and the problem mentioned in this topic (tag on deleted topic).