diff --git a/docs/changelog.txt b/docs/changelog.txt index a031d1bc..91d7a48f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -17,6 +17,7 @@ - replaced Common/XoopsConfirm by Common/Confirm(mamba/goffy) - table renaming in fieldelements (goffy) - added new fieldelements integer/float (goffy) +- uninstall with bak-file creation (mamba/goffy)
3.5.1 Beta 1 [NOT RELEASED]
Dev: XOOPS 2.5.11, PHP 7.4.25, PHP 8.0.12, PHP 8.1.0 Beta 4 - semantic versioning (mamba) diff --git a/files/commonfiles/include/uninstall.php b/files/commonfiles/include/uninstall.php index dfec04dd..81024446 100644 --- a/files/commonfiles/include/uninstall.php +++ b/files/commonfiles/include/uninstall.php @@ -35,27 +35,23 @@ function xoops_module_uninstall_modulebuilder(\XoopsModule $module) $helper = Modulebuilder\Helper::getInstance(); - $utility = new Modulebuilder\Utility(); - $success = true; $helper->loadLanguage('admin'); //------------------------------------------------------------------ - // Remove uploads folder (and all subfolders) if they exist + // Rename uploads folder to BAK and add date to name //------------------------------------------------------------------ - - $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; - foreach ($old_directories as $old_dir) { - $dirInfo = new \SplFileInfo($old_dir); - if ($dirInfo->isDir()) { - // The directory exists so delete it - if (!$utility::rrmdir($old_dir)) { - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); - $success = false; - } + $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); + $dirInfo = new \SplFileInfo($uploadDirectory); + if ($dirInfo->isDir()) { + // The directory exists so rename it + $date = date('Y-m-d'); + if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { + $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); + $success = false; } - unset($dirInfo); } + unset($dirInfo); /* //------------ START ---------------- //------------------------------------------------------------------