From 4500b149898f7a22ed85ad362e3981b2f3518acc Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 20 Jul 2015 14:20:43 +0200 Subject: [PATCH] Use previousAttributes when model is destroyed fixes #5589 --- core/server/data/xml/sitemap/base-generator.js | 4 ++++ core/server/models/post.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/server/data/xml/sitemap/base-generator.js b/core/server/data/xml/sitemap/base-generator.js index 25591782f6..7f945ccd9f 100644 --- a/core/server/data/xml/sitemap/base-generator.js +++ b/core/server/data/xml/sitemap/base-generator.js @@ -136,6 +136,10 @@ _.extend(BaseSiteMapGenerator.prototype, { removeUrl: function (model) { var datum = model.toJSON(); + // When the model is destroyed we need to fetch previousAttributes + if (!datum.id) { + datum = model.previousAttributes(); + } this.removeFromLookups(datum); this.lastModified = Date.now(); diff --git a/core/server/models/post.js b/core/server/models/post.js index 4f9946b631..eff7229fa8 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -107,7 +107,6 @@ Post = ghostBookshelf.Model.extend({ if (model.previous('status') === 'published') { model.emitChange('unpublished'); } - model.emitChange('deleted'); }); },