Auto Close topic after 24 or 96 hours not working as expected

AI-generated summary

DeanMarkTaylor reported a bug in Discourse 1.3.0.beta7 where topics set to auto-close 24 or 96 hours after the last reply were closing immediately if the last post predated the setting. codinghorror noted that major sites like Boing Boing use this feature without issue, suggesting the problem might be specific to the “close after last reply” logic. DeanMarkTaylor hypothesized that the system incorrectly calculates the duration from the moment the rule is applied rather than waiting for the full duration to pass. riking proposed adding a warning message to inform users if the last post is already older than the specified duration, accompanied by a UI update. codinghorror confirmed this behavior was indeed a bug, stating the rule should not apply retroactively to existing posts. riking submitted a fix via PR #3481 to validate the time and skip the queue if the condition is met immediately. sam questioned if the fix was active while the PR was pending. Finally, techAPJ confirmed the issue was resolved after the fix was merged into the codebase.

This may have been caught and fixed already…

When a topic is set to close after 24 or 96 hours after last reply it appears close immediately.

96 and 24 are the only values I have tried.

The following post is added after a minute or so:

This topic was automatically closed 0 minutes after the last reply. New replies are no longer allowed.

This has not been tested on latest - but it was in this version:
Discourse 1.3.0.beta7 - https://github.com/discourse/discourse version 875a013ec76e7ce0cbb95a61223cbbd16ed31d4a

I did however check the first line of all commit comments for the last 17 days - only one mentioned “auto” and it wasn’t to do with closing a topic.


After thought

The last post was 10 days ago however.

But I was expecting the topic to close 24 / 96 hours from the time it was set to auto close (if there wasn’t a new post before then).

If this was broken we would know as BBS boing boing would have problems. They have an auto close main category there.

Possible there is an issue with close after last reply though. We can try it on this topic.

I’m guessing it’s that applying an “Auto Close based on last post” to a topic where the last post is older than the Auto Close duration closes it immediately…
… which for me was unexpected - as I wished for at least the Auto Close duration to pass first.

2 curtidas

Okay, I think a warning in that case would suffice. And fixing the close message.

<div class="warning">
    <i class="fa fa-warning"></i> The last post in the topic is already 24 hours old, so the topic will be closed immediately.
  </div>

4 curtidas

Well that is a bug @neil it should not apply to the last post at the time of creating the rule!

1 curtida

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

If you give a time for “after the last post” that would apply to right now, it gives you a warning, and skips the queue if you submit.


edit: should added tests

6 curtidas

Is this really fixed? PR is still in Limbo @riking Fixes for topic auto closing by riking · Pull Request #3481 · discourse/discourse · GitHub

1 curtida

Can you add this to your list @techapj to check into, eventually.

1 curtida

Merged in via:

https://github.com/discourse/discourse/commit/e52852dd0f2bd2f185466d16165565bbc1f29a2c

Thanks @riking :tada:

5 curtidas