mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Protects against too long strings when logging web services events
SVN:1.2[1961]
This commit is contained in:
@@ -283,12 +283,26 @@ abstract class WebServicesBase
|
||||
$oLog->Set('userinfo', UserRights::GetUser());
|
||||
$oLog->Set('verb', $sVerb);
|
||||
$oLog->Set('result', $oRes->IsOk());
|
||||
$oLog->Set('log_info', $oRes->GetInfoAsText());
|
||||
$oLog->Set('log_warning', $oRes->GetWarningsAsText());
|
||||
$oLog->Set('log_error', $oRes->GetErrorsAsText());
|
||||
$oLog->Set('data', $oRes->GetReturnedDataAsText());
|
||||
$this->TrimAndSetValue($oLog, 'log_info', $oRes->GetInfoAsText());
|
||||
$this->TrimAndSetValue($oLog, 'log_warning', $oRes->GetWarningsAsText());
|
||||
$this->TrimAndSetValue($oLog, 'log_error', $oRes->GetErrorsAsText());
|
||||
$this->TrimAndSetValue($oLog, 'data', $oRes->GetReturnedDataAsText());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
|
||||
protected function TrimAndSetValue($oLog, $sAttCode, $sValue)
|
||||
{
|
||||
$oAttDef = MetaModel::GetAttributeDef(get_class($oLog), $sAttCode);
|
||||
if (is_object($oAttDef))
|
||||
{
|
||||
$iMaxSize = $oAttDef->GetMaxSize();
|
||||
if ($iMaxSize)
|
||||
{
|
||||
$sValue = substr($sValue, 0, $iMaxSize);
|
||||
}
|
||||
$oLog->Set($sAttCode, $sValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to set a scalar attribute
|
||||
|
||||
Reference in New Issue
Block a user