Skip to content

Commit 5323004

Browse files
committed
- uninstall with bak-file creation
1 parent 3fb2d81 commit 5323004

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- replaced Common/XoopsConfirm by Common/Confirm(mamba/goffy)
1818
- table renaming in fieldelements (goffy)
1919
- added new fieldelements integer/float (goffy)
20+
- uninstall with bak-file creation (mamba/goffy)
2021

2122
<h5>3.5.1 Beta 1 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.25, PHP 8.0.12, PHP 8.1.0 Beta 4
2223
- semantic versioning (mamba)

files/commonfiles/include/uninstall.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,23 @@ function xoops_module_uninstall_modulebuilder(\XoopsModule $module)
3535

3636
$helper = Modulebuilder\Helper::getInstance();
3737

38-
$utility = new Modulebuilder\Utility();
39-
4038
$success = true;
4139
$helper->loadLanguage('admin');
4240

4341
//------------------------------------------------------------------
44-
// Remove uploads folder (and all subfolders) if they exist
42+
// Rename uploads folder to BAK and add date to name
4543
//------------------------------------------------------------------
46-
47-
$old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
48-
foreach ($old_directories as $old_dir) {
49-
$dirInfo = new \SplFileInfo($old_dir);
50-
if ($dirInfo->isDir()) {
51-
// The directory exists so delete it
52-
if (!$utility::rrmdir($old_dir)) {
53-
$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
54-
$success = false;
55-
}
44+
$uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
45+
$dirInfo = new \SplFileInfo($uploadDirectory);
46+
if ($dirInfo->isDir()) {
47+
// The directory exists so rename it
48+
$date = date('Y-m-d');
49+
if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
50+
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory));
51+
$success = false;
5652
}
57-
unset($dirInfo);
5853
}
54+
unset($dirInfo);
5955
/*
6056
//------------ START ----------------
6157
//------------------------------------------------------------------

0 commit comments

Comments
 (0)