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 1/2] 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); From c8090a03613d433bb28dac7655463004494f61b3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 26 Nov 2022 10:13:48 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/modulebuilder/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 91f038983f6..de3059b264f 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1642,10 +1642,10 @@ if ($dirins && $action == 'confirm_deletemodule') { // Dir for module $dir = $dirins.'/'.$modulelowercase; - + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - // Dir for module + // Dir for module $dir = dol_buildpath($modulelowercase, 0); // Zip file to build @@ -1668,8 +1668,8 @@ if ($dirins && $action == 'confirm_deletemodule') { dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); exit; } - - $moduleobj->remove(); + + $moduleobj->remove(); $result = dol_delete_dir_recursive($dir);