The Yearly Review plugin keeps creating new topics

Hi!

A yearly review was created on my forum. The topic was renamed, and because the yearly review plugin checks for identical title names to know if it has to create a new yearly review, it created another one 24 hours after.

I deleted the new one, renamed the first one with the default title.

But the plugin still creates new topics after 24 hours.

Here’s what data explorer returns:

SELECT created_at, title, fancy_title
FROM topics
WHERE title like '%2022%année en cours de révision%'
AND deleted_at IS NULL
ORDER BY created_at DESC
created_at title fancy_title
2023-01-04T14:52:19.345Z 2022 : l'année en cours de révision 2022 : l’année en cours de révision
2023-01-01T10:09:20.503Z 2022 : l'année en cours de révision 2022 : l’année en cours de révision

:information_source: it actually created new ones 3 times, maybe because of a difference between a quote and a fancy quote[1] in the title so I had to, hence the 3 days date difference and the only 2 results, but I’d like to keep only the first created one.

Any idea why the plugin continues to create topics despite having an existing one with the default title, and how to stop it from doing so? What if I disable it and re-enable it at the end of 2023? Will it create a topic 24h after I re-enable it?
Plus, that would not be the most elegant solution, so I’d like to know where exactly the issue comes from :thinking:

I’ll disable the plugin for the next days/weeks until the issue is identified and the new yearly reviews creations are prevented.


  1. See the anecdote here: A few questions about the yearly review plugin ↩︎

Did you also change the author to a different user?
The code looks for a topic with that title created by the system user.

Hi!
So, I’m the co-admin. I have only changed the name. I haven’t changed the author.
What if there are 2 topics with the same name and system user as author? Would it take the last one?

It doesn’t “take” one, it checks if such a topic exists, and if it doesn’t then it will create one.
If there are one or two (or 999) then it will not create a new one.

1 Like

So, there’s something wrong somewhere as it keeps creating new topics while one already exists :thinking:

1 Like

As @Maxence_C said, only the title was changed, so the author is still @system.

As far as I know, this condition is met. :person_shrugging:

3 Likes

Did you update yearly_review.topic_title, or just rename the topic?

1 Like

We just renamed the first yearly review topic’s title and then renamed it back to the default more than 24 hours after it was created.
We didn’t change yearly_review.topic_title.

3 Likes

If the title of the topic is an exact match of the title that was set when the topic was initially published, new review topics should be prevented from being published by this line:

return if Topic.where(user: Discourse.system_user, title: title).exists?

Unless the cause of the issue is that the title isn’t an exact match, maybe the issue is related to the topic being published in French. It would be great to know what is getting set as title here when the job is run:

title = I18n.t("yearly_review.topic_title", year: review_year)

I’m wondering if it’s trying to match the English title against the French title. Is French the default locale on your site?

Edit: if the topic is getting published with a French title, then title in the code above must be getting set in French. So that’s unlikely to be the cause of the issue.

4 Likes

They are identical, unless I missed a tiny difference in the two topics data explorer returned. I can provide more data if needed.

Should I run that in the rails console or elsewhere?

Yes, it is.


I’ll re-enable the plugin to check again if I can gather some more info on the next created yearly review (if there is one).

2 Likes

Well, I triggered manually the job, and it created a topic. Triggering it again won’t create a new yearly review.

I could move the replies from the first topic to the new one, and delete the first one and it should circumvent the problem.

But I’m very curious about what happens here and why the requirements seem not met despite what I see in the database.

1 Like

Me too. I’m not sure what’s going on, but it seems that this check for an existing topic is a little flaky:

return if Topic.where(user: Discourse.system_user, title: title).exists?

I’m wondering if anyone on the Discourse team have ideas about how to improve it.

Having to disable the plugin to prevent multiple topics from being created isn’t a great approach. The plugin loads some CSS that’s used to style its topics. If the plugin is disabled, I don’t think the CSS gets loaded.

2 Likes

Just a note: the plugin was updated with the new French translation, hence it created another new yearly review today :sweat_smile:
I’ve copied the title of this new topic, deleted it, and renamed the original one by pasting the title.
We’ll see if it creates a new topic tomorrow despite my copy-paste of the raw title.

3 Likes

Thanks for following up on this. Relying on the topic’s title to prevent creating multiple review topics is a really flaky approach (that’s my fault.) Once January ends, the issue won’t come up again until next year. @JammyDodger, maybe you could pass a note to the Discourse team to look into coming up with a better way of preventing multiple topics from being created. That should get done before January 2024. Time sure flies :slight_smile:

9 Likes

I think I can do that. :slight_smile: :+1:

4 Likes