2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00
Ghost/core/server
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
..
adapters Moved utils constants to lib/constants 2017-12-14 14:13:40 +01:00
api Proper error handling for permissible implementations 2018-02-21 16:59:48 +01:00
apps Redirected /amp links to original post when AMP is disabled (#9496) 2018-03-19 16:11:48 +07:00
config Update Notification improvements (#9123) 2018-01-09 15:20:00 +01:00
controllers Moved tokens, url safe and safe string utility to lib/security 2017-12-14 13:38:00 +01:00
data 🐛Fixed misspelled schema.org type for WebSite (#9526) 2018-03-23 10:50:28 +07:00
helpers 🐛Added more language support to {{reading_time}} helper (#9509) 2018-03-22 10:27:02 +07:00
lib Fix Node.js 4.x compatibility (#9503) 2018-03-15 09:50:25 +00:00
models 🐛 Fixed updated_at not being updated (#9532) 2018-03-26 14:12:02 +01:00
public 🛠 🙈 Rename ghost-url.js to ghost-sdk.js (#8767) 2017-07-28 18:23:32 +04:00
services Sorted out the mixed usages of include and withRelated (#9425) 2018-02-15 10:53:53 +01:00
translations Proper error handling for permissible implementations 2018-02-21 16:59:48 +01:00
views Fixed error trying to render 404 for missing asset 2017-12-22 20:08:59 +00:00
web 🐛Fixed asset redirects (#9455) 2018-02-14 17:21:31 +01:00
analytics-events.js Cleared out old unused events 2017-12-13 09:08:25 +00:00
filters.js Moved pipeline/sequence to lib/promise 2017-12-13 22:20:02 +01:00
ghost-server.js Always require fs-extra - consistency change 2017-12-13 20:57:11 +01:00
index.js Theme translations and blog localisation (#8437) 2018-01-09 14:50:57 +01:00
overrides.js Set Promise to be Bluebird globally 2017-12-13 20:57:11 +01:00
update-check.js Update Notification improvements (#9123) 2018-01-09 15:20:00 +01:00