Ghost/core/server/models/base/plugins
Kevin Ansfield 256f16a01f
🐛 Fixed URLs not being correctly transformed during insert operations (#13618)
closes https://github.com/TryGhost/Team/issues/1150

Our override of the base Bookshelf `insert` operation so that our own `formatOnWrite()` method is called on attributes was working on a false assumption that an `attrs` attribute is passed in as it is for the `update` operation. Instead Bookshelf's base update uses the `model.attributes` values to create an `attrs` object that is then passed through the usual `.format()` method meaning that our `insert` override was not actually doing anything.

- added a failing regression test for the `formatOnWrite()` override behaviour
- adjusted our insert/update overrides to set an internal `_isWriting` property on the model, then if that property is true our `.format()` override (which is called by Bookshelf on a generated `attrs` object during inserts) we manually call our `.formatOnWrite()` method
  - updated both overrides even though `update` was working for consistency and less cognitive overhead for reasoning between two different approaches
2021-10-20 15:22:46 +01:00
..
actions.js Moved Bookshelf plugins to folder 2021-06-17 12:04:38 +01:00
bulk-operations.js Added bulkEdit to bulk-operations bookshelf plugin (#13223) 2021-08-13 12:19:02 +01:00
crud.js 🐛 Fixed a 500 error for incorrect fields parameter in API 2021-07-06 11:58:37 +04:00
data-manipulation.js Moved Bookshelf plugins to folder 2021-06-17 12:04:38 +01:00
events.js Updated signature of Bookshelf model listeners 2021-09-10 16:59:11 +01:00
filtered-collection.js Moved Bookshelf plugins to folder 2021-06-17 12:04:38 +01:00
generate-slug.js Moved Bookshelf plugins to folder 2021-06-17 12:04:38 +01:00
overrides.js 🐛 Fixed URLs not being correctly transformed during insert operations (#13618) 2021-10-20 15:22:46 +01:00
raw-knex.js Removed explicit loading of Bookshelf registry plugin 2021-09-10 16:59:11 +01:00
sanitize.js Fixed indenting for Bookshelf sanitize plugin JSDoc 2021-06-17 13:01:15 +01:00
user-type.js Moved Bookshelf plugins to folder 2021-06-17 12:04:38 +01:00