mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°2589 - Infinite loops when logging with a Contact having a non empty TagSet field
Add ListParameters to DBSearch for nested queries
This commit is contained in:
@@ -2097,4 +2097,9 @@ class DBObjectSearch extends DBSearch
|
||||
}
|
||||
return $oExpression;
|
||||
}
|
||||
|
||||
public function ListParameters()
|
||||
{
|
||||
return $this->GetCriteria()->ListParameters();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1230,6 +1230,8 @@ abstract class DBSearch
|
||||
*/
|
||||
public abstract function GetCriteria();
|
||||
|
||||
public abstract function ListParameters();
|
||||
|
||||
/**
|
||||
* Shortcut to add efficient IN condition
|
||||
*
|
||||
|
||||
@@ -728,4 +728,14 @@ class DBUnionSearch extends DBSearch
|
||||
$oSearch->AddConditionExpression($oInCondition);
|
||||
}
|
||||
}
|
||||
|
||||
public function ListParameters()
|
||||
{
|
||||
$aParameters = array();
|
||||
foreach ($this->aSearches as $oSearch)
|
||||
{
|
||||
$aParameters = array_merge($aParameters, $oSearch->ListParameters());
|
||||
}
|
||||
return $aParameters;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2624,7 +2624,7 @@ class IntervalExpression extends Expression
|
||||
|
||||
public function ListParameters()
|
||||
{
|
||||
return array();
|
||||
return $this->m_oValue->ListParameters();
|
||||
}
|
||||
|
||||
public function RenameParam($sOldName, $sNewName)
|
||||
|
||||
47
test/core/ExpressionTest.php
Normal file
47
test/core/ExpressionTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use Expression;
|
||||
|
||||
class ExpressionTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
/**
|
||||
* @dataProvider ListParametersProvider
|
||||
* @param $sOQL
|
||||
* @param $aExpected
|
||||
*
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function testListParameters($sOQL, $aExpected)
|
||||
{
|
||||
$oExpression = Expression::FromOQL($sOQL);
|
||||
$aParameters = $oExpression->ListParameters();
|
||||
$aResult = array();
|
||||
foreach ($aParameters as $oVarExpr)
|
||||
{
|
||||
/** var \VariableExpression $oVarExpr */
|
||||
$aResult[] = $oVarExpr->RenderExpression();
|
||||
}
|
||||
$this->debug($aResult);
|
||||
$this->assertSame(array_diff($aExpected, $aResult), array_diff($aResult, $aExpected));
|
||||
}
|
||||
|
||||
public function ListParametersProvider()
|
||||
{
|
||||
return array(
|
||||
array('1', array()),
|
||||
array(':id = 2', array(':id')),
|
||||
array('expiration_date < DATE_SUB(NOW(), INTERVAL :expiration_days DAY)', array(':expiration_days')),
|
||||
array('id IN (SELECT Organization WHERE :id = 2)', array(':id')),
|
||||
array('id IN (:id, 2)', array(':id')),
|
||||
array("B.name LIKE :name", array(':name')),
|
||||
array("name REGEXP :regexp", array(':regexp')),
|
||||
array(" t.agent_id = :current_contact_id", array(':current_contact_id')),
|
||||
array("INET_ATON(dev.managementip) > INET_ATON('10.22.32.224') AND INET_ATON(:ip) < INET_ATON('10.22.32.255')", array(':ip')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -402,6 +402,7 @@ class OQLTest extends ItopDataTestCase
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->debug($e->getMessage());
|
||||
$sExceptionClass = get_class($e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user