From 60257cec096cf2ec82d724cc0568c85f947607a1 Mon Sep 17 00:00:00 2001 From: Delthair <41671350+Delthair@users.noreply.github.com> Date: Sat, 26 Nov 2022 10:06:39 +0100 Subject: [PATCH] Fix #22998 Disabled module before delete (modulebuilder) Ensure that the module is disabled before delete --- htdocs/modulebuilder/index.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 538b1cac290..91f038983f6 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1642,6 +1642,34 @@ if ($dirins && $action == 'confirm_deletemodule') { // Dir for module $dir = $dirins.'/'.$modulelowercase; + + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + // Dir for module + $dir = dol_buildpath($modulelowercase, 0); + + // Zip file to build + $FILENAMEZIP = ''; + + // Load module + dol_include_once($pathtofile); + $class = 'mod'.$module; + + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } else { + $error++; + $langs->load("errors"); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $moduleobj->remove(); $result = dol_delete_dir_recursive($dir);