FIX: Topics should honor auto-close when published to category (PR #8963)

This is my attempt to fix the issue outlined at: https://meta.discourse.org/t/not-autoclosing-topics-published-from-another-category/138898

I suspect there may be more to the puzzle, but in any case, I’m looking forward to any feedback.

GitHub

You’ve signed the CLA, tshenry. Thank you! This pull request is ready for review.

This looks like it could be the correct solution, but we’re going to need a test to confirm it’s working.

The test should run the auto publish job with an auto-close set on the category, then confirm that the new published topic has the correct setting.

This is my first go at writing a test, so let me know if I need to tweak anything!

Any reasons you need to “reload” the topic from the database?

      topic.inherit_auto_close_from_category

You’ll notice that topic is taken from the original TopicTimer. This ends up storing the topic with its starting category_id in topic. We need to run inherit_auto_close_from_category against the topic after it’s published to the new category and has an updated category_id. There may be a better way to handle this, but hopefully that at least explains the rationale behind the reload.

1 Like