Просмотр исходного кода

fix #434: Remove all of PageGroupRelations when remove page completely

Yuki Takei 7 лет назад
Родитель
Сommit
1a05ad13a0
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      lib/models/page.js

+ 3 - 0
lib/models/page.js

@@ -1066,6 +1066,7 @@ module.exports = function(crowi) {
       , Attachment = crowi.model('Attachment')
       , Comment = crowi.model('Comment')
       , Revision = crowi.model('Revision')
+      , PageGroupRelation = crowi.model('PageGroupRelation')
       , Page = this
       , pageId = pageData._id
       ;
@@ -1085,6 +1086,8 @@ module.exports = function(crowi) {
         return Page.removePageById(pageId);
       }).then(function(done) {
         return Page.removeRedirectOriginPageByPath(pageData.path);
+      }).then(function(done) {
+        return PageGroupRelation.removeAllByPage(pageData);
       }).then(function(done) {
         pageEvent.emit('delete', pageData, user); // update as renamed page
         resolve(pageData);