From d7d00b44f63899ece1171158e8386b0045303d41 Mon Sep 17 00:00:00 2001 From: scienceasdf Date: Mon, 14 Dec 2020 03:51:44 +0800 Subject: [PATCH] fix: search engine broken when renaming or moving pages (#2815) For building suggest in elasticsearch, the safeContent field will be splitted into arrays. If the page is renamed or moved, the server will throw error: "Cannot read property 'split' of Undefined", and the index will be broken. Here two lines are added to fix this issue. --- server/models/pages.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/models/pages.js b/server/models/pages.js index c452365e..16f5b2f1 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -544,6 +544,8 @@ module.exports = class Page extends Model { await WIKI.models.pages.rebuildTree() // -> Rename in Search Index + const pageContents = await WIKI.models.pages.query().findById(page.id).select('render') + page.safeContent = WIKI.models.pages.cleanHTML(pageContents.render) await WIKI.data.searchEngine.renamed({ ...page, destinationPath: opts.destinationPath,