Skip to content

Commit

Permalink
Merge pull request #177 from humhub/fix/40-hard-delete-on-disable-module
Browse files Browse the repository at this point in the history
Hard delete records on disable module
  • Loading branch information
luke- authored May 1, 2023
2 parents 59aee94 + 75a0152 commit 3bd9376
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function onIntegrityCheck($event)
// If parent_folder_id is 0 or null its an old root child which is not merged yet.
if (!empty($file->parent_folder_id) && empty($file->parentFolder)) {
if ($integrityController->showFix("Deleting cfile id " . $file->id . " without existing parent!")) {
$file->delete();
$file->hardDelete();
}
}
}
Expand All @@ -66,7 +66,7 @@ public static function onIntegrityCheck($event)
// If parent_folder_id is 0 or null its either an old root child which is not merged yet or an root directory.
if (!empty($folder->parent_folder_id) && empty($folder->parentFolder)) {
if ($integrityController->showFix("Deleting cfile folder id " . $folder->id . " without existing parent!")) {
$folder->delete();
$folder->hardDelete();
}
}
}
Expand Down
15 changes: 6 additions & 9 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use humhub\components\console\Application as ConsoleApplication;
use humhub\modules\cfiles\models\ConfigureContainerForm;
use humhub\modules\cfiles\models\rows\FileSystemItemRow;
use humhub\modules\content\models\ContentContainer;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
use humhub\modules\content\components\ContentContainerModule;
Expand Down Expand Up @@ -90,11 +89,11 @@ public function getPermissions($contentContainer = null)
*/
public function disable()
{
foreach (Folder::find()->all() as $key => $folder) {
$folder->delete();
foreach (Folder::find()->all() as $folder) {
$folder->hardDelete();
}
foreach (File::find()->all() as $key => $file) {
$file->delete();
foreach (File::find()->all() as $file) {
$file->hardDelete();
}
parent::disable();
}
Expand All @@ -104,13 +103,11 @@ public function disable()
*/
public function disableContentContainer(ContentContainerActiveRecord $container)
{

foreach (Folder::find()->contentContainer($container)->all() as $folder) {
$folder->delete();
$folder->hardDelete();
}

foreach (File::find()->contentContainer($container)->all() as $file) {
$file->delete();
$file->hardDelete();
}
parent::disableContentContainer($container);
}
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

0.16.1 - Unreleased
-----------------------
- Fix #177: Hard delete records on disable module

0.16.0 - April 27, 2023
-----------------------
- Enh: Added support for hidden files in stream
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"organisation",
"sharing"
],
"version": "0.16.0",
"version": "0.16.1",
"humhub": {
"minVersion": "1.14"
},
Expand Down

0 comments on commit 3bd9376

Please sign in to comment.