diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 14:12:33 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 14:12:33 +0200 |
| commit | ea8ee1d35948c6adc4a377c9eb77d99b2d856932 (patch) | |
| tree | 2a5c97180bd9f4ac8843379af46984d498db1412 /app/models | |
| parent | 8baac265059b70da0148487458ee4077b15f155e (diff) | |
Carry over other-locale translations when creating an autosave
Node#autosave! only copied assets forward onto a newly created
autosave, not translations. Invisible for single-locale nodes, but a
node with an existing multi-locale head/draft that gets locked and
edited in one locale would silently drop every other locale's
translation from the new autosave -- and from there into the draft
and eventually head, since save_draft! faithfully clones whatever
the autosave actually holds.
Fixed by using clone_attributes_from, which already does a complete
clone (translations, assets, tags, template, published_at) -- the
same method save_draft! already relies on two branches later, so no
new mechanism, just closing the one place still doing a partial,
hand-rolled version of it.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/node.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 6f435ee..535d8f1 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -80,7 +80,7 @@ class Node < ApplicationRecord | |||
| 80 | 80 | ||
| 81 | unless self.autosave | 81 | unless self.autosave |
| 82 | self.autosave = Page.create!(:editor => current_user) | 82 | self.autosave = Page.create!(:editor => current_user) |
| 83 | self.autosave.assets = (self.draft || self.head).assets if self.draft || self.head | 83 | self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head |
| 84 | self.save! | 84 | self.save! |
| 85 | end | 85 | end |
| 86 | self.autosave.assign_attributes(attributes) | 86 | self.autosave.assign_attributes(attributes) |
