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:
parent
d2adc08c18
commit
323074f106
2 changed files with 4 additions and 0 deletions
|
@ -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, () => {
|
||||
|
|
|
@ -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, () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue