Merge remote-tracking branch 'origin/develop' into feature/backoffice-full-moon-design

# Conflicts:
#	composer.json
#	css/light-grey.scss
#	lib/composer/autoload_classmap.php
#	lib/composer/autoload_static.php
This commit is contained in:
Molkobain
2020-09-08 17:30:32 +02:00
144 changed files with 19950 additions and 1687 deletions

View File

@@ -48,7 +48,7 @@ if (empty($sMemoryLimit))
// On some PHP installations, memory_limit does not exist as a PHP setting!
// (encountered on a 5.2.0 under Windows)
// In that case, ini_set will not work, let's keep track of this and proceed with the data load
SetupPage::log_info("No memory limit has been defined in this instance of PHP");
SetupLog::Info("No memory limit has been defined in this instance of PHP");
}
else
{
@@ -59,11 +59,11 @@ else
{
if (ini_set('memory_limit', SAFE_MINIMUM_MEMORY) === FALSE)
{
SetupPage::log_error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself.");
SetupLog::Error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself.");
}
else
{
SetupPage::log_info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY.".");
SetupLog::Info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY.".");
}
}
}
@@ -89,7 +89,7 @@ function ShutdownCallback()
$errline = $error["line"];
$errstr = $error["message"];
$sLogMessage = "PHP error occured : msg=$errstr, no=$errno, file=$errfile, line=$errline";
SetupPage::log_error("Setup error: $sLogMessage");
SetupLog::Error("Setup error: $sLogMessage");
echo '<'.PHP_FATAL_ERROR_TAG.'>'.$sLogMessage.'</'.PHP_FATAL_ERROR_TAG.'>';
}
@@ -188,17 +188,17 @@ catch(Exception $e)
header("HTTP/1.0 500 Internal server error.");
echo "<p>An error happened while processing the installation:</p>\n";
echo '<p>'.$e."</p>\n";
SetupPage::log_error("An error happened while processing the installation: ".$e);
SetupLog::Error("An error happened while processing the installation: ".$e);
}
if (function_exists('memory_get_peak_usage'))
{
if ($sOperation == 'file')
{
SetupPage::log_info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage());
SetupLog::Info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage());
}
else
{
SetupPage::log_info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage());
SetupLog::Info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage());
}
}

View File

@@ -189,7 +189,7 @@ class ApplicationInstaller
try
{
$fStart = microtime(true);
SetupPage::log_info("##### STEP {$sStep} start");
SetupLog::Info("##### STEP {$sStep} start");
$this->EnterReadOnlyMode();
switch ($sStep)
{
@@ -209,7 +209,7 @@ class ApplicationInstaller
$this->oParams->ToXML($oDoc, null, 'installation');
$sXML = $oDoc->saveXML();
$sSafeXml = preg_replace("|<pwd>([^<]*)</pwd>|", "<pwd>**removed**</pwd>", $sXML);
SetupPage::log_info("======= Installation starts =======\nParameters:\n$sSafeXml\n");
SetupLog::Info("======= Installation starts =======\nParameters:\n$sSafeXml\n");
// Save the response file as a stand-alone file as well
$sFileName = 'install-'.date('Y-m-d');
@@ -281,11 +281,11 @@ class ApplicationInstaller
if (function_exists('symlink'))
{
$bUseSymbolicLinks = true;
SetupPage::log_info("Using symbolic links instead of copying data model files (for developers only!)");
SetupLog::Info("Using symbolic links instead of copying data model files (for developers only!)");
}
else
{
SetupPage::log_info("Symbolic links (function symlinks) does not seem to be supported on this platform (OS/PHP version).");
SetupLog::Info("Symbolic links (function symlinks) does not seem to be supported on this platform (OS/PHP version).");
}
}
@@ -409,10 +409,10 @@ class ApplicationInstaller
'percentage-completed' => 100,
);
SetupPage::log_error('An exception occurred: '.$e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile());
SetupLog::Error('An exception occurred: '.$e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile());
$idx = 0;
// Log the call stack, but not the parameters since they may contain passwords or other sensitive data
SetupPage::log("Call stack:");
SetupLog::Ok("Call stack:");
foreach ($e->getTrace() as $aTrace)
{
$sLine = empty($aTrace['line']) ? "" : $aTrace['line'];
@@ -421,14 +421,14 @@ class ApplicationInstaller
$sType = empty($aTrace['type']) ? "" : $aTrace['type'];
$sFunction = empty($aTrace['function']) ? "" : $aTrace['function'];
$sVerb = empty($sClass) ? $sFunction : "$sClass{$sType}$sFunction";
SetupPage::log("#$idx $sFile($sLine): $sVerb(...)");
SetupLog::Ok("#$idx $sFile($sLine): $sVerb(...)");
$idx++;
}
}
finally
{
$fDuration = round(microtime(true) - $fStart, 2);
SetupPage::log_info("##### STEP {$sStep} duration: {$fDuration}s");
SetupLog::Info("##### STEP {$sStep} duration: {$fDuration}s");
}
return $aResult;
@@ -516,7 +516,7 @@ class ApplicationInstaller
protected static function DoCompile($aSelectedModules, $sSourceDir, $sExtensionDir, $sTargetDir, $sEnvironment, $bUseSymbolicLinks = false)
{
SetupPage::log_info("Compiling data model.");
SetupLog::Info("Compiling data model.");
require_once(APPROOT.'setup/modulediscovery.class.inc.php');
require_once(APPROOT.'setup/modelfactory.class.inc.php');
@@ -624,7 +624,7 @@ class ApplicationInstaller
$oMFCompiler->Compile($sTargetPath, null, $bUseSymbolicLinks);
//$aCompilerLog = $oMFCompiler->GetLog();
//SetupPage::log_info(implode("\n", $aCompilerLog));
SetupPage::log_info("Data model successfully compiled to '$sTargetPath'.");
SetupLog::Info("Data model successfully compiled to '$sTargetPath'.");
$sCacheDir = APPROOT.'/data/cache-'.$sEnvironment.'/';
SetupUtils::builddir($sCacheDir);
@@ -669,7 +669,7 @@ class ApplicationInstaller
*/
protected static function DoUpdateDBSchema($aSelectedModules, $sModulesDir, $aParamValues, $sTargetEnvironment = '', $bOldAddon = false, $sAppRootUrl = '')
{
SetupPage::log_info("Update Database Schema for environment '$sTargetEnvironment'.");
SetupLog::Info("Update Database Schema for environment '$sTargetEnvironment'.");
$sMode = $aParamValues['mode'];
$sDBPrefix = $aParamValues['db_prefix'];
$sDBName = $aParamValues['db_name'];
@@ -699,7 +699,7 @@ class ApplicationInstaller
// Starting 2.0, all table names must be lowercase
if ($sMode != 'install')
{
SetupPage::log_info("Renaming '{$sDBPrefix}priv_internalUser' into '{$sDBPrefix}priv_internaluser' (lowercase)");
SetupLog::Info("Renaming '{$sDBPrefix}priv_internalUser' into '{$sDBPrefix}priv_internaluser' (lowercase)");
// This command will have no effect under Windows...
// and it has been written in two steps so as to make it work under windows!
CMDBSource::SelectDB($sDBName);
@@ -710,36 +710,36 @@ class ApplicationInstaller
}
catch (Exception $e)
{
SetupPage::log_info("Renaming '{$sDBPrefix}priv_internalUser' failed (already done in a previous upgrade?)");
SetupLog::Info("Renaming '{$sDBPrefix}priv_internalUser' failed (already done in a previous upgrade?)");
}
// let's remove the records in priv_change which have no counterpart in priv_changeop
SetupPage::log_info("Cleanup of '{$sDBPrefix}priv_change' to remove orphan records");
SetupLog::Info("Cleanup of '{$sDBPrefix}priv_change' to remove orphan records");
CMDBSource::SelectDB($sDBName);
try
{
$sTotalCount = "SELECT COUNT(*) FROM `{$sDBPrefix}priv_change`";
$iTotalCount = (int)CMDBSource::QueryToScalar($sTotalCount);
SetupPage::log_info("There is a total of $iTotalCount records in {$sDBPrefix}priv_change.");
SetupLog::Info("There is a total of $iTotalCount records in {$sDBPrefix}priv_change.");
$sOrphanCount = "SELECT COUNT(c.id) FROM `{$sDBPrefix}priv_change` AS c left join `{$sDBPrefix}priv_changeop` AS o ON c.id = o.changeid WHERE o.id IS NULL";
$iOrphanCount = (int)CMDBSource::QueryToScalar($sOrphanCount);
SetupPage::log_info("There are $iOrphanCount useless records in {$sDBPrefix}priv_change (".sprintf('%.2f', ((100.0*$iOrphanCount)/$iTotalCount))."%)");
SetupLog::Info("There are $iOrphanCount useless records in {$sDBPrefix}priv_change (".sprintf('%.2f', ((100.0*$iOrphanCount)/$iTotalCount))."%)");
if ($iOrphanCount > 0)
{
SetupPage::log_info("Removing the orphan records...");
SetupLog::Info("Removing the orphan records...");
$sCleanup = "DELETE FROM `{$sDBPrefix}priv_change` USING `{$sDBPrefix}priv_change` LEFT JOIN `{$sDBPrefix}priv_changeop` ON `{$sDBPrefix}priv_change`.id = `{$sDBPrefix}priv_changeop`.changeid WHERE `{$sDBPrefix}priv_changeop`.id IS NULL;";
CMDBSource::Query($sCleanup);
SetupPage::log_info("Cleanup completed successfully.");
SetupLog::Info("Cleanup completed successfully.");
}
else
{
SetupPage::log_info("Ok, nothing to cleanup.");
SetupLog::Info("Ok, nothing to cleanup.");
}
}
catch (Exception $e)
{
SetupPage::log_info("Cleanup of orphan records in `{$sDBPrefix}priv_change` failed: ".$e->getMessage());
SetupLog::Info("Cleanup of orphan records in `{$sDBPrefix}priv_change` failed: ".$e->getMessage());
}
}
@@ -772,7 +772,7 @@ class ApplicationInstaller
$iCount = (int)CMDBSource::QueryToScalar($sCount);
if ($iCount > 0)
{
SetupPage::log_info("Initializing '{$sDBPrefix}priv_change.origin' ($iCount records to update)");
SetupLog::Info("Initializing '{$sDBPrefix}priv_change.origin' ($iCount records to update)");
// By default all uninitialized values are considered as 'interactive'
$sInit = "UPDATE `{$sDBPrefix}priv_change` SET `origin` = 'interactive' WHERE `origin` IS NULL";
@@ -802,17 +802,17 @@ class ApplicationInstaller
$sInit = "UPDATE `{$sDBPrefix}priv_change` SET `origin` = 'synchro-data-source' WHERE ($sCondition)";
CMDBSource::Query($sInit);
SetupPage::log_info("Initialization of '{$sDBPrefix}priv_change.origin' completed.");
SetupLog::Info("Initialization of '{$sDBPrefix}priv_change.origin' completed.");
}
else
{
SetupPage::log_info("'{$sDBPrefix}priv_change.origin' already initialized, nothing to do.");
SetupLog::Info("'{$sDBPrefix}priv_change.origin' already initialized, nothing to do.");
}
}
catch (Exception $e)
{
SetupPage::log_error("Initializing '{$sDBPrefix}priv_change.origin' failed: ".$e->getMessage());
SetupLog::Error("Initializing '{$sDBPrefix}priv_change.origin' failed: ".$e->getMessage());
}
// priv_async_task now has a 'status' field to distinguish between the various statuses rather than just relying on the date columns
@@ -824,27 +824,27 @@ class ApplicationInstaller
$iCount = (int)CMDBSource::QueryToScalar($sCount);
if ($iCount > 0)
{
SetupPage::log_info("Initializing '{$sDBPrefix}priv_async_task.status' ($iCount records to update)");
SetupLog::Info("Initializing '{$sDBPrefix}priv_async_task.status' ($iCount records to update)");
$sInit = "UPDATE `{$sDBPrefix}priv_async_task` SET `status` = 'planned' WHERE (`status` IS NULL) AND (`started` IS NULL)";
CMDBSource::Query($sInit);
$sInit = "UPDATE `{$sDBPrefix}priv_async_task` SET `status` = 'error' WHERE (`status` IS NULL) AND (`started` IS NOT NULL)";
CMDBSource::Query($sInit);
SetupPage::log_info("Initialization of '{$sDBPrefix}priv_async_task.status' completed.");
SetupLog::Info("Initialization of '{$sDBPrefix}priv_async_task.status' completed.");
}
else
{
SetupPage::log_info("'{$sDBPrefix}priv_async_task.status' already initialized, nothing to do.");
SetupLog::Info("'{$sDBPrefix}priv_async_task.status' already initialized, nothing to do.");
}
}
catch (Exception $e)
{
SetupPage::log_error("Initializing '{$sDBPrefix}priv_async_task.status' failed: ".$e->getMessage());
SetupLog::Error("Initializing '{$sDBPrefix}priv_async_task.status' failed: ".$e->getMessage());
}
SetupPage::log_info("Database Schema Successfully Updated for environment '$sTargetEnvironment'.");
SetupLog::Info("Database Schema Successfully Updated for environment '$sTargetEnvironment'.");
}
/**
@@ -864,7 +864,7 @@ class ApplicationInstaller
$bOldAddon
)
{
SetupPage::log_info('After Database Creation');
SetupLog::Info('After Database Creation');
$sMode = $aParamValues['mode'];
$oConfig = new Config();
@@ -898,7 +898,7 @@ class ApplicationInstaller
}
else
{
SetupPage::log_info("Administrator account '$sAdminUser' created.");
SetupLog::Info("Administrator account '$sAdminUser' created.");
}
}
@@ -913,7 +913,7 @@ class ApplicationInstaller
*/
protected static function CreateAdminAccount(Config $oConfig, $sAdminUser, $sAdminPwd, $sLanguage)
{
SetupPage::log_info('CreateAdminAccount');
SetupLog::Info('CreateAdminAccount');
if (UserRights::CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage))
{
@@ -1032,7 +1032,7 @@ class ApplicationInstaller
{
mkdir(APPCONF);
chmod(APPCONF, 0770); // RWX for owner and group, nothing for others
SetupPage::log_info("Created configuration directory: ".APPCONF);
SetupLog::Info("Created configuration directory: ".APPCONF);
}
// Write the final configuration file
@@ -1056,11 +1056,11 @@ class SetupDBBackup extends DBBackup
{
protected function LogInfo($sMsg)
{
SetupPage::log('Info - '.$sMsg);
SetupLog::Ok('Info - '.$sMsg);
}
protected function LogError($sMsg)
{
SetupPage::log('Error - '.$sMsg);
SetupLog::Ok('Error - '.$sMsg);
}
}

View File

@@ -60,6 +60,7 @@ class MFCompiler
protected $aSnippets;
protected $aRelations;
protected $sEnvironment;
protected $sCompilationTimeStamp;
public function __construct($oModelFactory, $sEnvironment)
{
@@ -74,7 +75,8 @@ class MFCompiler
$this->sMainPHPCode .= " * This file was automatically generated by the compiler on ".date('Y-m-d H:i:s')." -- DO NOT EDIT\n";
$this->sMainPHPCode .= " */\n";
$this->sMainPHPCode .= "\n";
$this->sMainPHPCode .= "define('COMPILATION_TIMESTAMP', '".microtime(true)."');\n";
$this->sCompilationTimeStamp = "".microtime(true);
$this->sMainPHPCode .= "define('COMPILATION_TIMESTAMP', '".$this->sCompilationTimeStamp."');\n";
$this->aSnippets = array();
$this->aRelations = array();
}
@@ -2687,6 +2689,7 @@ EOF;
'variables' => array(),
'imports' => array(),
'stylesheets' => array(),
'precompiled_stylesheet' => '',
);
/** @var \DOMNodeList $oVariables */
@@ -2712,7 +2715,7 @@ EOF;
$sStylesheetId = $oStylesheet->getAttribute('id');
$aThemeParameters['stylesheets'][$sStylesheetId] = $oStylesheet->GetText();
}
$aThemeParameters['precompiled_stylesheet'] = $oTheme->GetChildText('precompiled_stylesheet', '');
$aThemes[$sThemeId] = $aThemeParameters;
}
@@ -2724,6 +2727,7 @@ EOF;
}
// Compile themes
$fStart = microtime(true);
foreach($aThemes as $sThemeId => $aThemeParameters)
{
$sThemeDir = $sThemesDir.$sThemeId;
@@ -2731,10 +2735,29 @@ EOF;
{
SetupUtils::builddir($sThemeDir);
}
// Check if a precompiled version of the theme is supplied
$sPrecompiledFile = $sTempTargetDir.$aThemeParameters['precompiled_stylesheet'];
if (file_exists($sPrecompiledFile))
{
copy($sPrecompiledFile, $sThemeDir.'/main.css');
// Make sure that the copy of the precompiled file is older than any other files to force a validation of the signature
touch($sThemeDir.'/main.css', 1577836800 /* 2020-01-01 00:00:00 */);
}
else if ($sPrecompiledFile != '')
{
$this->Log("Precompiled file not found: '$sPrecompiledFile'");
}
$bHasCompiled = ThemeHandler::CompileTheme($sThemeId, true, $this->sCompilationTimeStamp, $aThemeParameters, $aImportsPaths, $sTempTargetDir);
$sInitialPrecompiledFilePath = APPROOT.'datamodels/2.x/'.$aThemeParameters['precompiled_stylesheet'];
if ($bHasCompiled && is_file($sInitialPrecompiledFilePath))
{
SetupLog::Info("Replacing precompiled file $sInitialPrecompiledFilePath for theme $sThemeId for next setup.");
copy($sThemeDir.'/main.css', $sInitialPrecompiledFilePath);
}
ThemeHandler::CompileTheme($sThemeId, $aThemeParameters, $aImportsPaths, $sTempTargetDir);
}
$this->Log(sprintf('Themes compilation took: %.3f ms for %d themes.', (microtime(true) - $fStart)*1000.0, count($aThemes)));
}
/**

View File

@@ -450,18 +450,18 @@ class iTopExtensionsMap
if (count($aModuleInfo) === 0)
{
SetupPage::log_warning("Eval of $sModuleFile did not return the expected information...");
SetupLog::Warning("Eval of $sModuleFile did not return the expected information...");
}
}
catch(ParseError $e)
{
// Continue...
SetupPage::log_warning("Eval of $sModuleFile caused a parse error: ".$e->getMessage()." at line ".$e->getLine());
SetupLog::Warning("Eval of $sModuleFile caused a parse error: ".$e->getMessage()." at line ".$e->getLine());
}
catch(Exception $e)
{
// Continue...
SetupPage::log_warning("Eval of $sModuleFile caused an exception: ".$e->getMessage());
SetupLog::Warning("Eval of $sModuleFile caused an exception: ".$e->getMessage());
}
return $aModuleInfo;
}

View File

@@ -337,7 +337,7 @@ class ModuleDiscovery
$bOk = @eval('$bResult = '.$sBooleanExpr.'; return true;');
if ($bOk == false)
{
SetupPage::log_warning("Eval of '$sBooleanExpr' returned false");
SetupLog::Warning("Eval of '$sBooleanExpr' returned false");
echo "Failed to parse the boolean Expression = '$sBooleanExpr'<br/>";
}
}
@@ -467,7 +467,7 @@ class ModuleDiscovery
if ($bRet === false)
{
SetupPage::log_warning("Eval of $sRelDir/$sFile returned false");
SetupLog::Warning("Eval of $sRelDir/$sFile returned false");
}
//echo "<p>Done.</p>\n";
@@ -475,12 +475,12 @@ class ModuleDiscovery
catch(ParseError $e)
{
// PHP 7
SetupPage::log_warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()." at line ".$e->getLine());
SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()." at line ".$e->getLine());
}
catch(Exception $e)
{
// Continue...
SetupPage::log_warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage());
SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage());
}
}
}
@@ -503,27 +503,27 @@ class SetupWebPage extends ModuleDiscovery
// For backward compatibility with old modules...
public static function log_error($sText)
{
SetupPage::log_error($sText);
SetupLog::Error($sText);
}
public static function log_warning($sText)
{
SetupPage::log_warning($sText);
SetupLog::Warning($sText);
}
public static function log_info($sText)
{
SetupPage::log_info($sText);
SetupLog::Info($sText);
}
public static function log_ok($sText)
{
SetupPage::log_ok($sText);
SetupLog::Ok($sText);
}
public static function log($sText)
{
SetupPage::log($sText);
SetupLog::Ok($sText);
}
}

View File

@@ -95,12 +95,12 @@ abstract class ModuleInstallerAPI
$sRepair = "UPDATE `$sTableName` SET `$sFinalClassCol` = '$sTo' WHERE `$sFinalClassCol` = BINARY '$sFrom'";
CMDBSource::Query($sRepair);
$iAffectedRows = CMDBSource::AffectedRows();
SetupPage::log_info("Renaming class in DB - final class from '$sFrom' to '$sTo': $iAffectedRows rows affected");
SetupLog::Info("Renaming class in DB - final class from '$sFrom' to '$sTo': $iAffectedRows rows affected");
}
}
catch(Exception $e)
{
SetupPage::log_warning("Failed to rename class in DB - final class from '$sFrom' to '$sTo'. Reason: ".$e->getMessage());
SetupLog::Warning("Failed to rename class in DB - final class from '$sFrom' to '$sTo'. Reason: ".$e->getMessage());
}
}
@@ -122,7 +122,7 @@ abstract class ModuleInstallerAPI
{
if (!MetaModel::IsValidAttCode($sClass, $sAttCode))
{
SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - from '$sFrom' to '$sTo' failed. Reason '$sAttCode' is not a valid attribute of the class '$sClass'.");
SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - from '$sFrom' to '$sTo' failed. Reason '$sAttCode' is not a valid attribute of the class '$sClass'.");
return;
}
$sOriginClass = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
@@ -162,7 +162,7 @@ abstract class ModuleInstallerAPI
if (strtolower($sTo) == strtolower($sFrom))
{
SetupPage::log_info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo' (just a change in the case)");
SetupLog::Info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo' (just a change in the case)");
$aTargetValues = array();
foreach ($aCurrentValues as $sValue)
{
@@ -180,7 +180,7 @@ abstract class ModuleInstallerAPI
{
// 1st - Allow both values in the column definition
//
SetupPage::log_info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo'");
SetupLog::Info("Changing enum in DB - $sClass::$sAttCode from '$sFrom' to '$sTo'");
$aAllValues = $aCurrentValues;
$aAllValues[] = $sTo;
$sColumnDefinition = "ENUM(".implode(",", CMDBSource::Quote($aAllValues)).") $sNullSpec";
@@ -192,7 +192,7 @@ abstract class ModuleInstallerAPI
$sRepair = "UPDATE `$sTableName` SET `$sEnumCol` = '$sTo' WHERE `$sEnumCol` = BINARY '$sFrom'";
CMDBSource::Query($sRepair);
$iAffectedRows = CMDBSource::AffectedRows();
SetupPage::log_info("Changing enum in DB - $iAffectedRows rows updated");
SetupLog::Info("Changing enum in DB - $iAffectedRows rows updated");
// 3rd - Remove the useless value from the column definition
//
@@ -208,25 +208,25 @@ abstract class ModuleInstallerAPI
$sColumnDefinition = "ENUM(".implode(",", CMDBSource::Quote($aTargetValues)).") $sNullSpec";
$sRepair = "ALTER TABLE `$sTableName` MODIFY `$sEnumCol` $sColumnDefinition";
CMDBSource::Query($sRepair);
SetupPage::log_info("Changing enum in DB - removed useless value '$sFrom'");
SetupLog::Info("Changing enum in DB - removed useless value '$sFrom'");
}
}
}
else
{
SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sFrom' is still a valid value (".implode(', ', $aNewValues).")");
SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sFrom' is still a valid value (".implode(', ', $aNewValues).")");
}
}
else
{
SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' is not a known value (".implode(', ', $aNewValues).")");
SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' is not a known value (".implode(', ', $aNewValues).")");
}
}
}
}
catch(Exception $e)
{
SetupPage::log_warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' failed. Reason ".$e->getMessage());
SetupLog::Warning("Changing enum in DB - $sClass::$sAttCode - '$sTo' failed. Reason ".$e->getMessage());
}
}

View File

@@ -884,19 +884,19 @@ class RunTimeEnvironment
*/
protected function log_error($sText)
{
SetupPage::log_error($sText);
SetupLog::Error($sText);
}
protected function log_warning($sText)
{
SetupPage::log_warning($sText);
SetupLog::Warning($sText);
}
protected function log_info($sText)
{
SetupPage::log_info($sText);
SetupLog::Info($sText);
}
protected function log_ok($sText)
{
SetupPage::log_ok($sText);
SetupLog::Ok($sText);
}
/**
@@ -1088,7 +1088,7 @@ class RunTimeEnvironment
isset($aAvailableModules[$sModuleId]['installer']) )
{
$sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer'];
SetupPage::log_info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
SetupLog::Info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
$aCallSpec = array($sModuleInstallerClass, $sHandlerName);
if (is_callable($aCallSpec))
{
@@ -1110,8 +1110,8 @@ class RunTimeEnvironment
CMDBObject::SetTrackInfo("Initialization");
$oMyChange = CMDBObject::GetCurrentChange();
SetupPage::log_info("starting data load session");
SetupLog::Info("starting data load session");
$oDataLoader->StartSession($oMyChange);
$aFiles = array();
@@ -1161,7 +1161,7 @@ class RunTimeEnvironment
foreach($aPreviouslyLoadedFiles as $sFileRelativePath)
{
$sFileName = APPROOT.$sFileRelativePath;
SetupPage::log_info("Loading file: $sFileName (just to get the keys mapping)");
SetupLog::Info("Loading file: $sFileName (just to get the keys mapping)");
if (empty($sFileName) || !file_exists($sFileName))
{
throw(new Exception("File $sFileName does not exist"));
@@ -1169,13 +1169,13 @@ class RunTimeEnvironment
$oDataLoader->LoadFile($sFileName, true);
$sResult = sprintf("loading of %s done.", basename($sFileName));
SetupPage::log_info($sResult);
SetupLog::Info($sResult);
}
foreach($aFiles as $sFileRelativePath)
{
$sFileName = APPROOT.$sFileRelativePath;
SetupPage::log_info("Loading file: $sFileName");
SetupLog::Info("Loading file: $sFileName");
if (empty($sFileName) || !file_exists($sFileName))
{
throw(new Exception("File $sFileName does not exist"));
@@ -1183,11 +1183,11 @@ class RunTimeEnvironment
$oDataLoader->LoadFile($sFileName);
$sResult = sprintf("loading of %s done.", basename($sFileName));
SetupPage::log_info($sResult);
SetupLog::Info($sResult);
}
$oDataLoader->EndSession();
SetupPage::log_info("ending data load session");
SetupLog::Info("ending data load session");
}
/**

View File

@@ -151,26 +151,27 @@ class SetupPage extends NiceWebPage
return parent::output();
}
//@deprecated since 2.8.0 use SetupLog::Error
public static function log_error($sText)
{
SetupLog::Error($sText);
}
//@deprecated since 2.8.0 use SetupLog::Warning
public static function log_warning($sText)
{
SetupLog::Warning($sText);
}
//@deprecated since 2.8.0 use SetupLog::Info
public static function log_info($sText)
{
SetupLog::Info($sText);
}
//@deprecated since 2.8.0 use SetupLog::Ok
public static function log_ok($sText)
{
SetupLog::Ok($sText);
}
//@deprecated since 2.8.0 use SetupLog::Ok
public static function log($sText)
{
SetupLog::Ok($sText);

View File

@@ -136,29 +136,8 @@ class SetupUtils
$aWritableDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'env-production-build', 'conf', 'data'));
$aResult = array_merge($aResult, $aWritableDirsErrors);
$aMandatoryExtensions = array(
'mysqli',
'iconv',
'simplexml',
'soap',
'hash',
'json',
'session',
'pcre',
'dom',
'zlib',
'gd', // test image type (always returns false if not installed), image resizing, PDF export
);
$aOptionalExtensions = array(
'mcrypt, sodium or openssl' =>
array(
'mcrypt' => 'Strong encryption will not be used.',
'sodium' => 'Strong encryption will not be used.',
'openssl' => 'Strong encryption will not be used.',
),
'ldap' => 'LDAP authentication will be disabled.',
'mbstring' => 'For CryptEngine implementations, trace in Mail to ticket automation', // N°2891
);
$aMandatoryExtensions = self::GetPHPMandatoryExtensions();
$aOptionalExtensions = self::GetPHPOptionalExtensions();
asort($aMandatoryExtensions); // Sort the list to look clean !
ksort($aOptionalExtensions); // Sort the list to look clean !
@@ -253,7 +232,7 @@ class SetupUtils
}
}
}
SetupPage::log("Info - php.ini file(s): '$sPhpIniFile'");
SetupLog::Ok("Info - php.ini file(s): '$sPhpIniFile'");
}
if (!ini_get('file_uploads'))
@@ -280,7 +259,7 @@ class SetupUtils
}
else
{
SetupPage::log("Info - Temporary directory for files upload ($sUploadTmpDir) is writable.");
SetupLog::Ok("Info - Temporary directory for files upload ($sUploadTmpDir) is writable.");
}
}
@@ -305,9 +284,9 @@ class SetupUtils
}
SetupPage::log("Info - upload_max_filesize: ".ini_get('upload_max_filesize'));
SetupPage::log("Info - post_max_size: ".ini_get('post_max_size'));
SetupPage::log("Info - max_file_uploads: ".ini_get('max_file_uploads'));
SetupLog::Ok("Info - upload_max_filesize: ".ini_get('upload_max_filesize'));
SetupLog::Ok("Info - post_max_size: ".ini_get('post_max_size'));
SetupLog::Ok("Info - max_file_uploads: ".ini_get('max_file_uploads'));
// Check some more ini settings here, needed for file upload
$sMemoryLimit = trim(ini_get('memory_limit'));
@@ -329,7 +308,7 @@ class SetupUtils
}
else
{
SetupPage::log("Info - memory_limit is $iMemoryLimit, ok.");
SetupLog::Ok("Info - memory_limit is $iMemoryLimit, ok.");
}
}
@@ -353,7 +332,7 @@ class SetupUtils
}
else
{
SetupPage::log("Info - suhosin.get.max_value_length = $iGetMaxValueLength, ok.");
SetupLog::Ok("Info - suhosin.get.max_value_length = $iGetMaxValueLength, ok.");
}
}
@@ -380,7 +359,7 @@ class SetupUtils
if (ini_get('session.save_handler') == 'files')
{
$sSavePath = ini_get('session.save_path');
SetupPage::log("Info - session.save_path is: '$sSavePath'.");
SetupLog::Ok("Info - session.save_path is: '$sSavePath'.");
// According to the PHP documentation, the format can be /path/where/to_save_sessions or "N;/path/where/to_save_sessions" or "N;MODE;/path/where/to_save_sessions"
$sSavePath = ltrim(rtrim($sSavePath, '"'), '"'); // remove surrounding quotes (if any)
@@ -450,7 +429,7 @@ class SetupUtils
*/
private static function CheckPhpVersion(&$aResult)
{
SetupPage::log('Info - CheckPHPVersion');
SetupLog::Ok('Info - CheckPHPVersion');
$sPhpVersion = phpversion();
if (version_compare($sPhpVersion, self::PHP_MIN_VERSION, '>='))
@@ -497,7 +476,7 @@ class SetupUtils
public static function CheckSelectedModules($sSourceDir, $sExtensionDir, $aSelectedModules)
{
$aResult = array();
SetupPage::log('Info - CheckSelectedModules');
SetupLog::Ok('Info - CheckSelectedModules');
$aDirsToScan = array(APPROOT.$sSourceDir);
$sExtensionsPath = APPROOT.$sExtensionDir;
@@ -528,7 +507,7 @@ class SetupUtils
public static function CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir = null)
{
$aResult = array();
SetupPage::log('Info - CheckBackupPrerequisites');
SetupLog::Ok('Info - CheckBackupPrerequisites');
// zip extension
//
@@ -546,7 +525,7 @@ class SetupUtils
// availability of exec()
//
$aDisabled = explode(', ', ini_get('disable_functions'));
SetupPage::log('Info - PHP functions disabled: '.implode(', ', $aDisabled));
SetupLog::Ok('Info - PHP functions disabled: '.implode(', ', $aDisabled));
if (in_array('exec', $aDisabled))
{
$aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
@@ -564,7 +543,7 @@ class SetupUtils
}
else
{
SetupPage::log('Info - Found mysql_bindir: '.$sMySQLBinDir);
SetupLog::Ok('Info - Found mysql_bindir: '.$sMySQLBinDir);
$sMySQLDump = '"'.$sMySQLBinDir.'/mysqldump"';
}
$sCommand = "$sMySQLDump -V 2>&1";
@@ -588,7 +567,7 @@ class SetupUtils
}
foreach($aOutput as $sLine)
{
SetupPage::log('Info - mysqldump -V said: '.$sLine);
SetupLog::Ok('Info - mysqldump -V said: '.$sLine);
}
// create and test destination location
@@ -618,12 +597,12 @@ class SetupUtils
public static function CheckGraphviz($sGraphvizPath)
{
$oResult = null;
SetupPage::log('Info - CheckGraphviz');
SetupLog::Ok('Info - CheckGraphviz');
// availability of exec()
//
$aDisabled = explode(', ', ini_get('disable_functions'));
SetupPage::log('Info - PHP functions disabled: '.implode(', ', $aDisabled));
SetupLog::Ok('Info - PHP functions disabled: '.implode(', ', $aDisabled));
if (in_array('exec', $aDisabled))
{
$aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
@@ -653,7 +632,7 @@ class SetupUtils
}
foreach($aOutput as $sLine)
{
SetupPage::log('Info - '.$sGraphvizPath.' -V said: '.$sLine);
SetupLog::Ok('Info - '.$sGraphvizPath.' -V said: '.$sLine);
}
return $oResult;
@@ -726,11 +705,11 @@ class SetupUtils
{
if (!unlink($dir.'/'.$file))
{
SetupPage::log("Warning - FAILED to remove file '$dir/$file'");
SetupLog::Ok("Warning - FAILED to remove file '$dir/$file'");
}
else if (file_exists($dir.'/'.$file))
{
SetupPage::log("Warning - FAILED to remove file '$dir/.$file'");
SetupLog::Ok("Warning - FAILED to remove file '$dir/.$file'");
}
}
}
@@ -2115,13 +2094,58 @@ JS
{
if (class_exists('SetupPage'))
{
SetupPage::log($sText);
SetupLog::Ok($sText);
}
else
{
IssueLog::Info($sText);
}
}
/**
* @return string[]
*/
public static function GetPHPMandatoryExtensions(): array
{
return [
'mysqli',
'iconv',
'simplexml',
'soap',
'hash',
'json',
'session',
'pcre',
'dom',
'zlib',
'zip',
'fileinfo', // N°3123
'mbstring', // N°2899
'gd', // test image type (always returns false if not installed), image resizing, PDF export
];
}
/**
* @return array
*/
public static function GetPHPOptionalExtensions(): array
{
$aOptionalExtensions = [
'mcrypt, sodium or openssl' => [
'mcrypt' => 'Strong encryption will not be used.',
'sodium' => 'Strong encryption will not be used.',
'openssl' => 'Strong encryption will not be used.',
],
'ldap' => 'LDAP authentication will be disabled.',
'mbstring' => 'For CryptEngine implementations, trace in Mail to ticket automation', // N°2891
];
if (utils::IsDevelopmentEnvironment()) {
$aOptionalExtensions['xdebug'] = 'For debugging';
}
return $aOptionalExtensions;
}
}
/**

View File

@@ -193,7 +193,7 @@ class XMLDataLoader
{
if (!MetaModel::IsValidClass($sClass))
{
SetupPage::log_error("Unknown class - $sClass");
SetupLog::Error("Unknown class - $sClass");
throw(new Exception("Unknown class - $sClass"));
}
@@ -245,7 +245,7 @@ class XMLDataLoader
else
{
$sMsg = "Ext key not reconcilied - $sClass/$iSrcId - $sAttCode: '".$sQuery."' - found $iMatches matche(s)";
SetupPage::log_error($sMsg);
SetupLog::Error($sMsg);
$this->m_aErrors[] = $sMsg;
$iExtKey = 0;
}
@@ -291,7 +291,7 @@ class XMLDataLoader
{
// $res contains the error description
$sMsg = "Value not allowed - $sClass/$iSrcId - $sAttCode: '".$oSubNode."' ; $res";
SetupPage::log_error($sMsg);
SetupLog::Error($sMsg);
$this->m_aErrors[] = $sMsg;
}
$oTargetObj->Set($sAttCode, $value);
@@ -378,7 +378,7 @@ class XMLDataLoader
}
catch(Exception $e)
{
SetupPage::log_error("An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage());
SetupLog::Error("An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage());
$this->m_aErrors[] = "An object could not be recorded - $sClass/$iSrcId - ".$e->getMessage();
}
$aParentClasses = MetaModel::EnumParentClasses($sClass);
@@ -417,7 +417,7 @@ class XMLDataLoader
if ($iExtKey == 0)
{
$sMsg = "unresolved extkey in $sClass::".$oTargetObj->GetKey()."(".$oTargetObj->GetName().")::$sAttCode=$sTargetClass::$iTempKey";
SetupPage::log_warning($sMsg);
SetupLog::Warning($sMsg);
$this->m_aWarnings[] = $sMsg;
//echo "<pre>aKeys[".$sTargetClass."]:\n";
//print_r($this->m_aKeys[$sTargetClass]);