mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°3002 Get developer_mode.enabled config param first normally, and if not set from disk
This commit is contained in:
@@ -2827,13 +2827,12 @@ HTML;
|
||||
* @since 2.6.0 method creation
|
||||
* @since 3.0.0 add the `developer_mode.enabled` config parameter
|
||||
*
|
||||
* @uses developer_mode.enabled config parameter, but always read it from disk
|
||||
* @uses GetDeveloperModeParam
|
||||
* @uses ITOP_REVISION constant (check 'svn' value)
|
||||
*/
|
||||
public static function IsDevelopmentEnvironment()
|
||||
{
|
||||
$oConfig = utils::GetConfig(true);
|
||||
$bIsDevEnvInConfig = $oConfig->Get('developer_mode.enabled');
|
||||
$bIsDevEnvInConfig = static::GetDeveloperModeParam();
|
||||
if ($bIsDevEnvInConfig === true) {
|
||||
return true;
|
||||
}
|
||||
@@ -2851,7 +2850,36 @@ HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool : indicate whether we run under a windows environnement or not
|
||||
* In the setup there are times when the MetaModel config attribute is loaded but partially (only setup parameters are set, others have the default value)
|
||||
* So we need to load from disk then !
|
||||
*
|
||||
* But in other scenario we want to read from memory : for example when changing the option in a PHPUnit setUp method
|
||||
*
|
||||
* This method will first try to get the `developer_mode.enabled` config parameter the standard way (call to GetConfig without modification).
|
||||
* If we are getting null (not defined parameter), then we will load config from disk only (GetConfig(true))
|
||||
*
|
||||
* @return bool|null
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*
|
||||
* @uses developer_mode.enabled config parameter
|
||||
*/
|
||||
private static function GetDeveloperModeParam(): ?bool
|
||||
{
|
||||
$oConfig = static::GetConfig(false);
|
||||
$bIsDevEnvInConfig = $oConfig->Get('developer_mode.enabled');
|
||||
|
||||
if (!is_null($bIsDevEnvInConfig)) {
|
||||
return $bIsDevEnvInConfig;
|
||||
}
|
||||
|
||||
$oConfigFromDisk = static::GetConfig(true);
|
||||
|
||||
return $oConfigFromDisk->Get('developer_mode.enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if we are running under a Windows environment
|
||||
* @since 2.7.4 : N°3412
|
||||
*/
|
||||
public static function IsWindowsEnvironment()
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
namespace Combodo\iTop\Test\UnitTest\Core\Log;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use DeprecatedCallsLog;
|
||||
use ExceptionLog;
|
||||
use LogAPI;
|
||||
use MetaModel;
|
||||
|
||||
|
||||
@@ -32,18 +30,10 @@ class ExceptionLogTest extends ItopDataTestCase
|
||||
parent::setUp();
|
||||
|
||||
// We are using PHPUnit\Framework\MockObject\Generator::generateMock that is throwing notice !
|
||||
// Changing the log config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler
|
||||
// Changing config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler
|
||||
// disabling devenv is easier than changing log config O:)
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
$mLogLevelMin = $oConfig->Get('log_level_min');
|
||||
if (is_string($mLogLevelMin)) {
|
||||
$aLogLevelMin[''] = $mLogLevelMin;
|
||||
} else if (is_array($mLogLevelMin)) {
|
||||
$aLogLevelMin = $mLogLevelMin;
|
||||
} else {
|
||||
$aLogLevelMin = [];
|
||||
}
|
||||
$aLogLevelMin[DeprecatedCallsLog::ENUM_CHANNEL_PHP_LIBMETHOD] = LogAPI::LEVEL_ERROR;
|
||||
$oConfig->Set('log_level_min', $aLogLevelMin);
|
||||
$oConfig->Set('developer_mode.enabled', false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user