Fixed previews not reflecting changes to scheduled posts on Ghost(Pro) (#10601)

closes https://github.com/TryGhost/Ghost/issues/10600
- modifies conditions for when to send a cache invalidation header for preview URLs to include changes to scheduled posts
This commit is contained in:
Kevin Ansfield 2019-03-12 18:35:54 +00:00 committed by GitHub
parent 458a57b09d
commit 507d8b32db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -132,10 +132,15 @@ module.exports = {
query(frame) {
return models.Post.edit(frame.data.pages[0], frame.options)
.then((model) => {
if (model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published') {
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
) {
this.headers.cacheInvalidate = true;
} else if (model.get('status') === 'draft' && model.previous('status') !== 'published') {
} else if (
model.get('status') === 'draft' && model.previous('status') !== 'published' ||
model.get('status') === 'scheduled' && model.wasChanged()
) {
this.headers.cacheInvalidate = {
value: urlService.utils.urlFor({
relativeUrl: urlService.utils.urlJoin('/p', model.get('uuid'), '/')

View File

@ -136,10 +136,15 @@ module.exports = {
query(frame) {
return models.Post.edit(frame.data.posts[0], frame.options)
.then((model) => {
if (model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published') {
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
) {
this.headers.cacheInvalidate = true;
} else if (model.get('status') === 'draft' && model.previous('status') !== 'published') {
} else if (
model.get('status') === 'draft' && model.previous('status') !== 'published' ||
model.get('status') === 'scheduled' && model.wasChanged()
) {
this.headers.cacheInvalidate = {
value: urlService.utils.urlFor({
relativeUrl: urlService.utils.urlJoin('/p', model.get('uuid'), '/')