Fix can't disable a module that were removed.

This commit is contained in:
Laurent Destailleur 2015-09-04 16:47:43 +02:00
parent 9422b22edb
commit dcaef54f9b
2 changed files with 11 additions and 5 deletions

View File

@ -838,13 +838,13 @@ function unActivateModule($value, $requiredby=1)
} }
else else
{ {
// TODO Replace this afte DolibarrModules is moved as abstract class with a try catch to show module is bugged // TODO Replace this after DolibarrModules is moved as abstract class with a try catch to show module is bugged
$genericMod = new DolibarrModules($db); $genericMod = new DolibarrModules($db);
$genericMod->name=preg_replace('/^mod/i','',$modName); $genericMod->name=preg_replace('/^mod/i','',$modName);
$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName)); $genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName));
$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName)); $genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName));
dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName); dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName);
$genericMod->_remove(); $genericMod->_remove('');
} }
// Desactivation des modules qui dependent de lui // Desactivation des modules qui dependent de lui
@ -853,6 +853,7 @@ function unActivateModule($value, $requiredby=1)
$countrb=count($objMod->requiredby); $countrb=count($objMod->requiredby);
for ($i = 0; $i < $countrb; $i++) for ($i = 0; $i < $countrb; $i++)
{ {
var_dump($objMod->requiredby[$i]);
unActivateModule($objMod->requiredby[$i]); unActivateModule($objMod->requiredby[$i]);
} }
} }

View File

@ -32,7 +32,7 @@
* *
* Parent class for module descriptor class files * Parent class for module descriptor class files
*/ */
abstract class DolibarrModules class DolibarrModules // Can not be abstract, because we need to instantiant it into unActivateModule to be able to disable a module whose files were removed.
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
@ -194,16 +194,21 @@ abstract class DolibarrModules
*/ */
public $core_enabled; public $core_enabled;
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
//public function __construct($db);
// We should but can't set this as abstract because this will make dolibarr hang // We should but can't set this as abstract because this will make dolibarr hang
// after migration due to old module not implementing. We must wait PHP is able to make // after migration due to old module not implementing. We must wait PHP is able to make
// a try catch on Fatal error to manage this correctly. // a try catch on Fatal error to manage this correctly.
function __construct($db)
{
$this->db=$db;
}
/** /**
* Enables a module. * Enables a module.
* Inserts all informations into database * Inserts all informations into database