Fix: Error management with corrupted module files
This commit is contained in:
parent
37b0780523
commit
7aa2c9dcd1
@ -136,44 +136,57 @@ foreach ($modulesdir as $dir)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$res=include_once $dir.$file;
|
$res=include_once $dir.$file;
|
||||||
$objMod = new $modName($db);
|
if (class_exists($modName))
|
||||||
$modNameLoaded[$modName]=$dir;
|
{
|
||||||
|
try {
|
||||||
|
$objMod = new $modName($db);
|
||||||
|
$modNameLoaded[$modName]=$dir;
|
||||||
|
|
||||||
if ($objMod->numero > 0)
|
if ($objMod->numero > 0)
|
||||||
{
|
{
|
||||||
$j = $objMod->numero;
|
$j = $objMod->numero;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$j = 1000 + $i;
|
$j = 1000 + $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
$modulequalified=1;
|
$modulequalified=1;
|
||||||
|
|
||||||
// We discard modules according to features level (PS: if module is activated we always show it)
|
// We discard modules according to features level (PS: if module is activated we always show it)
|
||||||
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
|
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
|
||||||
if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
|
if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
|
||||||
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
|
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
|
||||||
// We discard modules according to property disabled
|
// We discard modules according to property disabled
|
||||||
if (isset($objMod->hidden) && $objMod->hidden) $modulequalified=false;
|
if (isset($objMod->hidden) && $objMod->hidden) $modulequalified=false;
|
||||||
|
|
||||||
// Define array $categ with categ with at least one qualified module
|
// Define array $categ with categ with at least one qualified module
|
||||||
if ($modulequalified)
|
if ($modulequalified)
|
||||||
{
|
{
|
||||||
$modules[$i] = $objMod;
|
$modules[$i] = $objMod;
|
||||||
$filename[$i]= $modName;
|
$filename[$i]= $modName;
|
||||||
$orders[$i] = $objMod->family."_".$j; // Sort by family, then by module number
|
$orders[$i] = $objMod->family."_".$j; // Sort by family, then by module number
|
||||||
$dirmod[$i] = $dir;
|
$dirmod[$i] = $dir;
|
||||||
// Set categ[$i]
|
// Set categ[$i]
|
||||||
$special = isset($specialtostring[$objMod->special])?$specialtostring[$objMod->special]:'unknown';
|
$special = isset($specialtostring[$objMod->special])?$specialtostring[$objMod->special]:'unknown';
|
||||||
if ($objMod->version == 'development' || $objMod->version == 'experimental') $special='expdev';
|
if ($objMod->version == 'development' || $objMod->version == 'experimental') $special='expdev';
|
||||||
if (isset($categ[$special])) $categ[$special]++; // Array of all different modules categories
|
if (isset($categ[$special])) $categ[$special]++; // Array of all different modules categories
|
||||||
else $categ[$special]=1;
|
else $categ[$special]=1;
|
||||||
$j++;
|
$j++;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
else dol_syslog("Module ".get_class($objMod)." not qualified");
|
else dol_syslog("Module ".get_class($objMod)." not qualified");
|
||||||
}
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||||
|
|||||||
@ -74,15 +74,27 @@ foreach($modulesdir as $dir)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// File to load
|
// File to load
|
||||||
include_once $dir.$file;
|
$res=include_once $dir.$file;
|
||||||
|
if (class_exists($modName))
|
||||||
$objMod = new $modName($db);
|
{
|
||||||
|
try {
|
||||||
$modules[$objMod->numero]=$objMod;
|
$objMod = new $modName($db);
|
||||||
$modules_names[$objMod->numero]=$objMod->name;
|
|
||||||
$modules_files[$objMod->numero]=$file;
|
$modules[$objMod->numero]=$objMod;
|
||||||
$modules_fullpath[$file]=$dir.$file;
|
$modules_names[$objMod->numero]=$objMod->name;
|
||||||
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
|
$modules_files[$objMod->numero]=$file;
|
||||||
|
$modules_fullpath[$file]=$dir.$file;
|
||||||
|
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user