N°4644 - Core update : confusing warning message when integrity of iTop std files is modified - List all modified files

This commit is contained in:
acognet
2022-03-14 14:43:54 +01:00
parent 0205cdf713
commit 4c99f497cc
34 changed files with 64 additions and 35 deletions

View File

@@ -56,7 +56,7 @@ class FilesInformation
try
{
FilesIntegrity::CheckInstallationIntegrity();
FilesIntegrity::CheckInstallationIntegrity(APPROOT, false);
}
catch (FileIntegrityException $e)
{

View File

@@ -81,8 +81,9 @@ class FilesIntegrity
* @param string $sRootPath
*
* @throws \Combodo\iTop\FilesInformation\Service\FileIntegrityException
* @since 2.7.7 3.0.1
*/
public static function CheckInstallationIntegrity($sRootPath = APPROOT)
public static function CheckInstallationIntegrity($sRootPath = APPROOT, $bExitAtFirstError = true)
{
$aFilesInfo = FilesIntegrity::GetInstalledFiles($sRootPath.'manifest.xml');
@@ -91,6 +92,9 @@ class FilesIntegrity
throw new FileIntegrityException(Dict::Format('FilesInformation:Error:MissingFile', 'manifest.xml'));
}
$bHasErrors = false;
$sErrorFiles ="";
@clearstatcache();
foreach ($aFilesInfo as $aFileInfo)
{
@@ -103,11 +107,19 @@ class FilesIntegrity
$sChecksum = md5($sContent);
if (($iSize != $aFileInfo['size']) || ($sChecksum != $aFileInfo['md5']))
{
throw new FileIntegrityException(Dict::Format('FilesInformation:Error:CorruptedFile', $sFile));
if($bExitAtFirstError) {
throw new FileIntegrityException(Dict::Format('FilesInformation:Error:CorruptedFile', $sFile));
} else {
$bHasErrors = true;
$sErrorFiles .='<li> '.$aFileInfo['path'].'</li>';
}
}
}
// Packed with missing files...
}
if($bHasErrors){
throw new FileIntegrityException(Dict::Format('FilesInformation:Error:ListCorruptedFile','<ul> '.$sErrorFiles.'</ul>'));
}
}
public static function IsInstallationConform($sRootPath, &$sErrorMsg)