diff --git a/datamodels/2.x/itop-core-update/src/Service/CoreUpdater.php b/datamodels/2.x/itop-core-update/src/Service/CoreUpdater.php index 31648367e..a1f651206 100644 --- a/datamodels/2.x/itop-core-update/src/Service/CoreUpdater.php +++ b/datamodels/2.x/itop-core-update/src/Service/CoreUpdater.php @@ -9,6 +9,7 @@ namespace Combodo\iTop\CoreUpdate\Service; +use Combodo\iTop\FilesInformation\Service\FileIntegrityException; use Combodo\iTop\FilesInformation\Service\FilesIntegrity; use DBBackup; use Dict; @@ -535,7 +536,11 @@ final class CoreUpdater SetupLog::Info('itop-core-update: Archive extracted, check files integrity'); // Check files integrity - FilesIntegrity::CheckInstallationIntegrity(self::UPDATE_DIR.'web/'); + $sRootPath = self::UPDATE_DIR.'web/'; + FilesIntegrity::CheckInstallationIntegrity($sRootPath); + + ///Check new modules + self::CheckNewModules($sRootPath); SetupLog::Info('itop-core-update: Files integrity OK'); } catch (Exception $e) @@ -604,4 +609,37 @@ final class CoreUpdater throw $e; } } + + /** + * Throw an exception if there are new modules that were not already installed + * @param $sRootPath + * + * @throws \ApplicationException + * @since 2.7.7 3.0.1 + */ + private static function CheckNewModules($sRootPath) + { + $aFilesInfo = FilesIntegrity::GetInstalledFiles($sRootPath.'manifest.xml'); + + if ($aFilesInfo === false) { + throw new FileIntegrityException(Dict::Format('FilesInformation:Error:MissingFile', 'manifest.xml')); + } + + @clearstatcache(); + $sSourceDir = MetaModel::GetConfig()->Get('source_dir'); + foreach ($aFilesInfo as $aFileInfo) { + if (strpos($aFileInfo['path'], $sSourceDir) === 0) { + $aFilePath = explode('/', $aFileInfo['path']); + $sFolderPath = $aFilePath[0].'/'.$aFilePath[1].'/'.$aFilePath[2]; + //if module don't already exist in itop and if module listed in manifest.xml is included in zip + if (!is_dir(APPROOT.'/'.$sFolderPath) && !is_file(APPROOT.'/'.$sFolderPath) + && is_dir($sRootPath.'/'.$sFolderPath)) { + $sLink = utils::GetAbsoluteUrlAppRoot().'setup/'; + $sLinkManualUpdate = 'https://www.itophub.io/wiki/page?id='.utils::GetItopVersionWikiSyntax().'%3Ainstall%3Aupgrading_itop#manually'; + throw new FileIntegrityException(Dict::Format('FilesInformation:Error:CannotUpdateNewModules', $sLink, $sLinkManualUpdate).'::'.$aFilePath[2]); + } + } + // Packed with missing files... + } + } }