discourse-category-experts/lib
Régis HANOL 6cae3c1cc6
FIX: Use save_custom_fields instead of save! when only custom fields changed (#230)
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
2026-04-02 18:25:34 +02:00
..
category_experts FIX: Use save_custom_fields instead of save! when only custom fields changed (#230) 2026-04-02 18:25:34 +02:00