Skip to content

A platform for community discussion. Free, open, simple.

FIX: Allow Symbol objects to be deserialized in PostRevision (#17510)

David Taylorf7740830162f
diff --git a/config/application.rb b/config/application.rb
index be44a6aa13b..ca71d106b8b 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -102,7 +102,7 @@ module Discourse
config.action_controller.forgery_protection_origin_check = false
config.active_record.belongs_to_required_by_default = false
config.active_record.legacy_connection_handling = true
- config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess, Time]
+ config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess, Time, Symbol]
# we skip it cause we configure it in the initializer
# the railtie for message_bus would insert it in the
diff --git a/spec/models/post_revision_spec.rb b/spec/models/post_revision_spec.rb
index 7bba51f7d60..e3e78e29270 100644
--- a/spec/models/post_revision_spec.rb
+++ b/spec/models/post_revision_spec.rb
@@ -23,4 +23,15 @@ describe PostRevision do
}
)
end
+
+ it "can serialize and deserialize symbols" do
+ # Plugins may store symbolized values in this column
+ pr = Fabricate(:post_revision, modifications: { key: :value })
+ pr.reload
+ expect(pr.modifications).to eq(
+ {
+ key: :value
+ }
+ )
+ end
end