Incorrect Count on /tags page (included deleted topics - now fixed)

Summary: Over at Stonehearth it was noticed by an Admin today that the count on the /tags page is incorrect for some tags.

Steps to reproduce:


Expected Results:

Number next to tags matches number of topics seen when viewing individual tag page.

Actual Results:

Number next to tags is greater than the number of topics seen when viewing individual tag page.


The difference between the number of topics with a tag and the number displayed appears to be constant i.e. ui had the number 5 but had 3 topics, adding the ui tag to another topics caused the number to increase to 6.

This is known to be an issue with the following tags (this list may be incomplete): ui, ai, crashes,


Version Number:

Discourse 1.7.0.beta7 (

System Information:

Windows 10 Education, Chrome Stable 54

Is it possible, it’s happening because of Topics deletion not reflected to Tags counting?


Also, Tags are still counted on any hidden topics/posts

just a thought, what are numbers when you are logged out, is it a permissions thing?

I checked adding ?status=deleted to the end to the URL, no deleted topics appeared. I’m a moderator so I would see unlisted topics, and the person who reported this to me is an Admin, so she would see if there were any topics in an admin category that I couldn’t see.

Same issue when logged out. Still seeing the number 6 but 4 topics for ui.

I don’t fully understand ‘make a topic into a private message’ yet, but i just made a topic, tagged it and turned it into a private message, and the tag count went up by one on the tag page.

could it be that?

deleting that private message keeps the tag count at +1

Certainly possible, but I highly, highly doubt it. We don’t use that function very much, and never for bug reports (the category where these tags are used).

I ran into this today and I think it’s caused by deleted topics.

Steps to reproduce:

  1. Create a new topic and add to it a new or existing tag;
  2. Navigate to the /tags page and memorize the count next to the tag you added to the new topic;
  3. Delete the new topic;
  4. Go back to the /tags page and you’ll see the tag count isn’t updated.

I can reproduce this constantly on my local install.


I’m also seeing this problem with deleted topics, exactly as @Osama describes. We’re using tags heavily in the project in question and have need to sometimes automatically create a large number of tagged topics (importing data from elsewhere). The auto-imports occasionally catch unrelated content and we delete the topics, but the orphaned tags and incorrect tag counts persist.


@clay do you have a step by step sequence on how we would reproduce this?

  1. Create a topic with tags

  2. Later, delete that topic.

The tags & count remain on the /tags page.

I’m happy to give you access to the instance in question. Just PM me if so.

edit: not sure if it matters, but in step 2, “Later” means like a week later. I mention this in case there’s a sidkiq job that runs on a delayed schedule that affects tag processing. For the instance in question, I deleted the topics mentioned months ago and the orphaned tags and incorrect counts remain.


@neil perhaps you can have a look at this?


I committed a fix for this issue. The counts won’t include deleted topics from now on.


This topic was automatically closed after 6 days. New replies are no longer allowed.