From 3c5352fb53d062d32bae57a84eacafab37061b02 Mon Sep 17 00:00:00 2001 From: Seyed Sajad Kahani Date: Mon, 29 Jun 2020 01:08:17 +0000 Subject: [PATCH] fix: change reconnectLink behavior for page move (#1991) --- server/models/pages.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/models/pages.js b/server/models/pages.js index 5689d6d2..37d0cc11 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -559,7 +559,7 @@ module.exports = class Page extends Model { }) } - // -> Reconnect Links + // -> Reconnect Links : Changing old links to the new path await WIKI.models.pages.reconnectLinks({ sourceLocale: page.localeCode, sourcePath: page.path, @@ -567,6 +567,13 @@ module.exports = class Page extends Model { path: opts.destinationPath, mode: 'move' }) + + // -> Reconnect Links : Validate invalid links to the new path + await WIKI.models.pages.reconnectLinks({ + locale: opts.destinationLocale, + path: opts.destinationPath, + mode: 'create' + }) } /** @@ -655,7 +662,7 @@ module.exports = class Page extends Model { break case 'move': const prevPageHref = `/${opts.sourceLocale}/${opts.sourcePath}` - replaceArgs.from = `` + replaceArgs.from = `` replaceArgs.to = `` break case 'delete':