From beec50f217f63f8d3c1dc9d4b319c8c8cf7fc24e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 13 Mar 2025 22:57:38 +0900 Subject: [PATCH] Prevent files from being deleted upon module deletion if they belong to documents or comments that have since been moved to a different module --- modules/file/file.controller.php | 12 ++++--- modules/file/queries/getModuleFilesProper.xml | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 modules/file/queries/getModuleFilesProper.xml diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 3bdd7c785..f77462546 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -1723,14 +1723,18 @@ class FileController extends File // Get a full list of attachments $args = new stdClass; $args->module_srl = $module_srl; - $output = executeQueryArray('file.getModuleFiles', $args); - if(!$output->toBool() || empty($file_list = $output->data)) + $output = executeQueryArray('file.getModuleFilesProper', $args); + if (!$output->toBool()) { return $output; } + if (!$output->data) + { + return; + } - // Delete the file - return $this->deleteFile($file_list); + // Delete each file. + return $this->deleteFile($output->data); } /** diff --git a/modules/file/queries/getModuleFilesProper.xml b/modules/file/queries/getModuleFilesProper.xml new file mode 100644 index 000000000..bbfb72108 --- /dev/null +++ b/modules/file/queries/getModuleFilesProper.xml @@ -0,0 +1,31 @@ + + + +
+ + + +
+ + + + +
+
+ + + + + + + + + + + + + + + + +