0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

🐛 Fixed error when deleting non-existent snippet

fixes https://github.com/TryGhost/Team/issues/809

- Bookshelf won't throw a `NotFoundError` unless `require=true` in the
  options
- this is present in most other API endpoints, so it's just simply
  missing from the snippet one
- without this, Ghost will crash with a 500 saying `Cannot read property
  'destroy' of null`
- this commit adds `require=true` to the destroy options for both the canary +
  v3 endpoints
This commit is contained in:
Daniel Lockyer 2021-06-24 09:58:35 +01:00
parent d2adc08c18
commit 323074f106
No known key found for this signature in database
GPG key ID: D21186F0B47295AD
2 changed files with 4 additions and 0 deletions

View file

@ -97,6 +97,8 @@ module.exports = {
},
permissions: true,
query(frame) {
frame.options.require = true;
return models.Snippet.destroy(frame.options)
.then(() => null)
.catch(models.Snippet.NotFoundError, () => {

View file

@ -97,6 +97,8 @@ module.exports = {
},
permissions: true,
query(frame) {
frame.options.require = true;
return models.Snippet.destroy(frame.options)
.then(() => null)
.catch(models.Snippet.NotFoundError, () => {