FIX: better edit conflict handling (#29789)

* FIX: better edit conflict handling

Properly keep track of the original title and tags when dealing with edit conflicts.

Internal ref - t/141218
This commit is contained in:
Régis Hanol
2024-12-03 10:12:04 +01:00
committed by GitHub
parent 89a6cac968
commit 806e37aaec
8 changed files with 150 additions and 52 deletions

View File

@ -240,8 +240,9 @@ class PostsController < ApplicationController
Post.plugin_permitted_update_params.keys.each { |param| changes[param] = params[:post][param] }
raw_old = params[:post][:raw_old]
if raw_old.present? && raw_old != post.raw
# keep `raw_old` for backwards compatibility
original_text = params[:post][:original_text] || params[:post][:raw_old]
if original_text.present? && original_text != post.raw
return render_json_error(I18n.t("edit_conflict"), status: 409)
end