Ghost/core/server/models
Katharina Irrgang 7c6f690eb5 🐛 Fixed updated_at not being updated (#9532)
closes #9520

- it contains a dependency bump of the latest Bookshelf release
- Bookshelf introduced a bug in the last release
  - see https://github.com/bookshelf/bookshelf/pull/1583
  - see https://github.com/bookshelf/bookshelf/pull/1798
- this has caused trouble in Ghost
  - the `updated_at` attribute was not automatically set anymore

---

The bookshelf added one breaking change: it's allow to pass custom `updated_at` and `created_at`.
We already have a protection for not being able to override the `created_at` date on update.
We had to add another protection to now allow to only change the `updated_at` property.
You can only change `updated_at` if you actually change something else e.g. the title of a post.

To be able to implement this check i discovered that Bookshelfs `model.changed` object has a tricky behaviour.
It remembers **all** attributes, which where changed, doesn't matter if they are valid or invalid model properties.
We had to add a line of code to avoid remembering none valid model attributes in this object.

e.g. you change `tag.parent` (no valid model attribute). The valid property is `tag.parent_id`.
     If you pass `tag.parent` but the value has **not** changed (`tag.parent` === `tag.parent_id`), it will output you `tag.changed.parent`. But this is wrong.
     Bookshelf detects `changed` attributes too early. Or if you think the other way around, Ghost detects valid attributes too late.
     But the current earliest possible stage is the `onSaving` event, there is no earlier way to pick valid attributes (except of `.forge`, but we don't use this fn ATM).
     Later: the API should transform `tag.parent` into `tag.parent_id`, but we are not using it ATM, so no need to pre-optimise.
     The API already transforms `post.author` into `post.author_id`.
2018-03-26 14:12:02 +01:00
..
base 🐛 Fixed updated_at not being updated (#9532) 2018-03-26 14:12:02 +01:00
plugins Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
accesstoken.js Import lib/common only 2017-12-12 10:28:13 +01:00
app-field.js Misc cleanup: moving files & naming functions 2015-06-15 09:43:19 +01:00
app-setting.js Misc cleanup: moving files & naming functions 2015-06-15 09:43:19 +01:00
app.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
client-trusted-domain.js Add table columns for OAuth 2015-09-02 13:39:22 +01:00
client.js 🎨 😎 config env usages (#7929) 2017-02-03 18:25:39 +00:00
index.js Webhooks support for subscriber events (#9230) 2017-11-21 15:43:14 +00:00
invite.js Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
permission.js Misc cleanup: moving files & naming functions 2015-06-15 09:43:19 +01:00
post.js Fixed wrong i18n key 2018-03-21 08:41:05 +01:00
refreshtoken.js Misc cleanup: moving files & naming functions 2015-06-15 09:43:19 +01:00
role.js Proper error handling for permissible implementations 2018-02-21 16:59:48 +01:00
settings.js Improved validation layer (#9427) 2018-02-16 00:49:15 +01:00
subscriber.js Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
tag.js 🐛Fixed image properties to be reset to null after removal (#9432) 2018-03-05 09:10:27 +01:00
user.js 🐛Fixed image properties to be reset to null after removal (#9432) 2018-03-05 09:10:27 +01:00
webhook.js Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00