Procházet zdrojové kódy

Fix: Consecutive page deletion requests cause unexpected complete page deletion

Yuki Takei před 6 roky
rodič
revize
42f4ddb15e
2 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 2 1
      CHANGES.md
  2. 5 4
      src/server/models/page.js

+ 2 - 1
CHANGES.md

@@ -2,7 +2,8 @@
 
 ## 3.5.4-RC
 
-* Bug: List private pages wrongly
+* Fix: List private pages wrongly
+* Fix: Consecutive page deletion requests cause unexpected complete page deletion
 
 ## 3.5.3
 

+ 5 - 4
src/server/models/page.js

@@ -1061,11 +1061,12 @@ module.exports = function(crowi) {
     const newPath = this.getDeletedPageName(pageData.path);
     const isTrashed = checkIfTrashed(pageData.path);
 
+    if (isTrashed) {
+      throw new Error('This method does NOT support deleting trashed pages.');
+    }
+
     const socketClientId = options.socketClientId || null;
     if (this.isDeletableName(pageData.path)) {
-      if (isTrashed) {
-        return this.completelyDeletePage(pageData, user, options);
-      }
 
       pageData.status = STATUS_DELETED;
       const updatedPageData = await this.rename(pageData, newPath, user, { socketClientId, createRedirectPage: true });
@@ -1084,7 +1085,7 @@ module.exports = function(crowi) {
     const isTrashed = checkIfTrashed(targetPage.path);
 
     if (isTrashed) {
-      return this.completelyDeletePageRecursively(targetPage, user, options);
+      throw new Error('This method does NOT supports deleting trashed pages.');
     }
 
     const findOpts = { includeRedirect: true };