main ← fix/save-custom-fields-during-owner-change
opened 03:41PM - 02 Apr 26 UTC
…lds changed
During user merges, `PostOwnerChanger` reassigns all post types …including small action posts which have `raw: nil` by design. The core `set_owner` method handles this correctly via `skip_validations: true`, but the plugin's `post_owner_changed` handler and `PostHandler` methods were calling `save!` after only modifying custom fields. This triggered full AR validations on the post body, raising `ActiveRecord::RecordInvalid` for posts with content that doesn't pass current validation rules.
Replace all `save!` calls with `save_custom_fields` in places where only custom fields are being modified — 8 occurrences across `plugin.rb` and `PostHandler` (`mark_post_for_approval`, `mark_post_as_approved`, `mark_topic_as_question`, `correct_topic_custom_fields_after_removal`, `correct_topic_custom_fields_after_addition`, `handle_topic_category_change`).
https://meta.discourse.org/t/399785