A platform for community discussion. Free, open, simple.
DEV: Fix Zeitwerk reloading in post-voting (#35470)
David Taylord9e0a44007f7
diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rbindex 72d3693007a..be57b618ff3 100644--- a/lib/plugin/instance.rb+++ b/lib/plugin/instance.rb@@ -395,7 +395,7 @@ class Plugin::Instance# Example usage:# register_preloaded_category_custom_fields("custom_field")def register_preloaded_category_custom_fields(field)- Site.preloaded_category_custom_fields << field+ reloadable_patch { Site.preloaded_category_custom_fields << field }enddef register_problem_check(klass)diff --git a/plugins/discourse-post-voting/plugin.rb b/plugins/discourse-post-voting/plugin.rbindex fba651d6010..05406a9f551 100644--- a/plugins/discourse-post-voting/plugin.rb+++ b/plugins/discourse-post-voting/plugin.rb@@ -202,12 +202,8 @@ after_initialize doendregister_category_custom_field_type(PostVoting::CREATE_AS_POST_VOTING_DEFAULT, :boolean)- if respond_to?(:register_preloaded_category_custom_fields)- register_preloaded_category_custom_fields(PostVoting::CREATE_AS_POST_VOTING_DEFAULT)- else- # TODO: Drop the if-statement and this if-branch in Discourse v3.2- Site.preloaded_category_custom_fields << PostVoting::CREATE_AS_POST_VOTING_DEFAULT- end+ register_preloaded_category_custom_fields(PostVoting::CREATE_AS_POST_VOTING_DEFAULT)+add_to_class(:category, :create_as_post_voting_default) doActiveModel::Type::Boolean.new.cast(self.custom_fields[PostVoting::CREATE_AS_POST_VOTING_DEFAULT],@@ -222,10 +218,9 @@ after_initialize doendregister_category_custom_field_type(PostVoting::ONLY_POST_VOTING_IN_THIS_CATEGORY, :boolean)- if Site.respond_to? :preloaded_category_custom_fields- Site.preloaded_category_custom_fields << PostVoting::ONLY_POST_VOTING_IN_THIS_CATEGORY- Site.preloaded_category_custom_fields << PostVoting::CREATE_AS_POST_VOTING_DEFAULT- end+ register_preloaded_category_custom_fields PostVoting::ONLY_POST_VOTING_IN_THIS_CATEGORY+ register_preloaded_category_custom_fields PostVoting::CREATE_AS_POST_VOTING_DEFAULT+add_to_class(:category, :only_post_voting_in_this_category) doActiveModel::Type::Boolean.new.cast(self.custom_fields[PostVoting::ONLY_POST_VOTING_IN_THIS_CATEGORY],