Fix: Error management with corrupted module files

This commit is contained in:
Laurent Destailleur 2013-12-08 02:32:04 +01:00
parent 37b0780523
commit 7aa2c9dcd1
2 changed files with 69 additions and 44 deletions

View File

@ -136,6 +136,9 @@ foreach ($modulesdir as $dir)
try try
{ {
$res=include_once $dir.$file; $res=include_once $dir.$file;
if (class_exists($modName))
{
try {
$objMod = new $modName($db); $objMod = new $modName($db);
$modNameLoaded[$modName]=$dir; $modNameLoaded[$modName]=$dir;
@ -179,6 +182,16 @@ foreach ($modulesdir as $dir)
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); 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)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
}
}
} }
} }
closedir($handle); closedir($handle);

View File

@ -74,8 +74,10 @@ 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))
{
try {
$objMod = new $modName($db); $objMod = new $modName($db);
$modules[$objMod->numero]=$objMod; $modules[$objMod->numero]=$objMod;
@ -84,6 +86,16 @@ foreach($modulesdir as $dir)
$modules_fullpath[$file]=$dir.$file; $modules_fullpath[$file]=$dir.$file;
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; $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>";
}
}
} }
} }
} }