0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed actions not stored when deleting posts

- if a model is being deleted, `attributes` is an empty object and the
  data we actually need is in `_previousAttributes`
- because of this, only fetching the type using `.get` returned the
  wrong value, and the Action model validator would throw an error
  because we tried to insert an empty type
- we can access the previous value using `.previous(..)`
- this commit fixes saving actions when deleting a post by fetching the
  type from the previous attributes if the current attributes is empty
This commit is contained in:
Daniel Lockyer 2022-08-19 13:18:23 +02:00
parent 1fadbacdec
commit ddd79494b0
No known key found for this signature in database
GPG key ID: D21186F0B47295AD

View file

@ -40,7 +40,7 @@ Post = ghostBookshelf.Model.extend({
actionsCollectCRUD: true,
actionsResourceType: function () {
return this.get('type');
return this.get('type') || this.previous('type');
},
/**