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
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
I’ll disable the plugin for the next days/weeks until the issue is identified and the new yearly reviews creations are prevented.
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.
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.
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.
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.
Just a note: the plugin was updated with the new French translation, hence it created another new yearly review today
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.
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