mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
Fix audit bug (DBUnionSearch::AddConditionForInOperatorUsingParam() does not exist) when category is a UNION and rule flag 'Valid objects?' is 'true' and there are invalid entries in the result of the audit.
This commit is contained in:
@@ -516,21 +516,6 @@ class DBObjectSearch extends DBSearch
|
||||
$this->AddConditionExpression($oInCondition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string a unique param name
|
||||
*/
|
||||
private function GenerateUniqueParamName() {
|
||||
$iExistingParamsNb = count($this->m_aParams);
|
||||
$iCurrentArrayParamNb = $iExistingParamsNb + 1;
|
||||
$sParamName = 'param'.$iCurrentArrayParamNb;
|
||||
|
||||
if (isset($this->m_aParams[$sParamName])) {
|
||||
$sParamName .= '_'.microtime(true) . '_' .rand(0,100);
|
||||
}
|
||||
|
||||
return $sParamName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a condition on external keys or link sets
|
||||
* @param string $sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
|
||||
|
||||
@@ -659,6 +659,15 @@ abstract class DBSearch
|
||||
*/
|
||||
public abstract function GetCriteria();
|
||||
|
||||
public abstract function AddConditionForInOperatorUsingParam($sFilterCode, $aValues, $bPositiveMatch = true);
|
||||
|
||||
/**
|
||||
* @return string a unique param name
|
||||
*/
|
||||
protected function GenerateUniqueParamName() {
|
||||
return str_replace('.', '', 'param_'.microtime(true).rand(0,100));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache/Trace/Log queries
|
||||
|
||||
@@ -628,4 +628,22 @@ class DBUnionSearch extends DBSearch
|
||||
$oSearch->SetDataFiltered();
|
||||
}
|
||||
}
|
||||
|
||||
public function AddConditionForInOperatorUsingParam($sFilterCode, $aValues, $bPositiveMatch = true)
|
||||
{
|
||||
$sInParamName = $this->GenerateUniqueParamName();
|
||||
foreach ($this->aSearches as $iSearchIndex => $oSearch)
|
||||
{
|
||||
$oFieldExpression = new FieldExpression($sFilterCode, $oSearch->GetClassAlias());
|
||||
|
||||
$sOperator = $bPositiveMatch ? 'IN' : 'NOT IN';
|
||||
|
||||
$oParamExpression = new VariableExpression($sInParamName);
|
||||
$oSearch->GetInternalParamsByRef()[$sInParamName] = $aValues;
|
||||
|
||||
$oListExpression = new ListExpression(array($oParamExpression));
|
||||
$oInCondition = new BinaryExpression($oFieldExpression, $sOperator, $oListExpression);
|
||||
$oSearch->AddConditionExpression($oInCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user