Tag gets broken if the first topic to use it is deleted

Hello,

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’ve just reproduced it using a throw away tag.

Created the tag, applied it to the post, deleted the post, unable to use that tag again ‘no matches found’, tag page empty.

anyone know where the tag goes and how to get it back?

In the meantime, try undeleting the topic and removing the tag from it. The URL of the topic appears on admin logs.

Thanks for the reply, i went to the logs and there are no mentions of deleting topics.

if i scroll back to earlier in the day though i can see one deleted topic, even though i have created and deleted many today.

sorry about this, any ideas? I’m more than happy to reinstall if necessary.

I could swear that topic deletion got logged :thinking:

Anyway, browse your latest page with the added parameter ?status=deleted just like example.com/?status=deleted

2 Likes

Thanks Rafael, that has worked.

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.

again, many thanks.

2 Likes

How fast did you delete the topic? Did you do it within the ninja edit window?

Hi cpradio,

I deleted the topic fairly fast by going to the topic and pressing the trash icon.

I have just re-deleted an un-deleted topic containing the ‘cambridge’ tag which is over 2 hours old and the tag has now gone again and is unuseable.

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.

educate until 0 doesn’t work either.

just an observation.

On my localhost I started 4 new topics, the first two “ninja deleted”, using the post wrench on one and the topic wrench on the other.

I’m leaving the second two to try deleting after a hopefully sufficient delay to see if things are different after Jobs have a chance to run

Indeed, there is no record of the deletions in the Staff Logs.

Neither “newtaga” nor “newtagb” show in the /tags page.

And when another member tried to create another “newtaga” tag, it was “not found” and could not be created.

Running SELECT * FROM tags shows the tags still exist in the tags table.

id 	name 	topic_count 	created_at 	updated_at
3	project	2	2016-06-04 23:41:05.143569	2016-06-04 23:41:05.143569
4	shelved	3	2016-06-04 23:41:05.146382	2016-06-04 23:41:05.146382
1	data_explorer	2	2016-06-04 23:41:05.130565	2016-06-04 23:41:05.130565
2	core	9	2016-06-04 23:41:05.141164	2016-06-04 23:41:05.141164
5	newtaga	1	2016-10-18 19:19:09.921612	2016-10-18 19:19:09.921612
6	newtagb	1	2016-10-18 19:22:04.011328	2016-10-18 19:22:04.011328
7	newtagd	1	2016-10-18 19:25:45.883148	2016-10-18 19:25:45.883148
8	newtagc	1	2016-10-18 19:28:05.605267	2016-10-18 19:28:05.605267

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

But it doesn’t show on the /tags page

3 Likes

https://github.com/discourse/discourse/pull/4511

7 Likes

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).

6 Likes