PRX / feeder.prx.org

Dovetail podcast content management system
https://podcasts.dovetail.prx.org
GNU Affero General Public License v3.0
5 stars 0 forks source link

Reject saving stale form data #1000

Closed cavis closed 4 months ago

cavis commented 4 months ago

So for the case:

  1. User A and User B load an episode form
  2. User A publishes episode
  3. User B edits the title and saves

Now the episode is unpublished again, with the new title from 3. This kind of conflict could really happen on any objects/fields.

We should handle with optimistic locking... the changes in (3) should be rejected. Rails/ActiveRecord has some built-ins for this, if you add a column. Or DIY it with updated_at?

Then we have some decisions after (3). What error message does User B get? Are their changes still in the unsaved-form? Can they opt to overwrite User A by clicking save a second time?

kookster commented 4 months ago

I'd probably try rails optimistic locking

https://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html

cavis commented 4 months ago

Yep, that's the "add a column" option. Though I do wonder if you could just wire that into the updated_at epoch.