diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index 4d4bc761c..954d8ee9e 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -1,21 +1,8 @@ -// +/* + * @copyright Copyright (C) 2010-2023 Combodo SARL + * @license http://opensource.org/licenses/AGPL-3.0 + */ /** @internal Dev hack for disabling some query build optimizations (Folding/Merging) */ define('ENABLE_OPT', true); @@ -2064,7 +2051,7 @@ class DBObjectSearch extends DBSearch * @param $sAttCode * @return \FunctionExpression|mixed|null * @throws \CoreException -*/ + */ static public function GetPolymorphicExpression($sClass, $sAttCode) { $oExpression = ExpressionCache::GetCachedExpression($sClass, $sAttCode); @@ -2140,7 +2127,7 @@ class DBObjectSearch extends DBSearch return $oExpression; } - public function ListParameters() + function GetExpectedArguments(): array { return $this->GetCriteria()->ListParameters(); } diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index b59fd6d75..84495097e 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -1,20 +1,8 @@ +/* + * @copyright Copyright (C) 2010-2023 Combodo SARL + * @license http://opensource.org/licenses/AGPL-3.0 + */ require_once('dbobjectiterator.php'); @@ -1482,7 +1470,7 @@ class DBObjectSet implements iDBObjectSetIterator public function ListConstantFields() { // The complete list of arguments will include magic arguments (e.g. current_user->attcode) - $aScalarArgs = MetaModel::PrepareQueryArguments($this->m_oFilter->GetInternalParams(), $this->m_aArgs, $this->m_oFilter->ListParameters()); + $aScalarArgs = MetaModel::PrepareQueryArguments($this->m_oFilter->GetInternalParams(), $this->m_aArgs, $this->m_oFilter->GetExpectedArguments()); $aConst = $this->m_oFilter->ListConstantFields(); foreach($aConst as $sClassAlias => $aVals) diff --git a/core/dbsearch.class.php b/core/dbsearch.class.php index a700abbc1..c4af180c2 100644 --- a/core/dbsearch.class.php +++ b/core/dbsearch.class.php @@ -1,49 +1,15 @@ GetCriteria()->ListParameters(); - } - /** * Generate a SQL query from the current search * @@ -1266,18 +1227,6 @@ abstract class DBSearch $aAttToLoad, $bGetCount, $aGroupByExpr = null, $aSelectedClasses = null, $aSelectExpr = null ); - /** - * Get the current search conditions - * - * @internal - * @see DBSearch $m_oSearchCondition - * - * @return \Expression - */ - public abstract function GetCriteria(); - - public abstract function ListParameters(); - /** * Shortcut to add efficient IN condition * @@ -1719,4 +1668,21 @@ abstract class DBSearch { return $this->ToOQL(true); } + + /** + * @return array{\VariableExpression} + * + * @deprecated use DBSearch::GetExpectedArguments() instead + */ + public function ListParameters(): array + { + return $this->GetExpectedArguments(); + } + + /** + * Get parameters from the condition expression(s) + * + * @return array{\VariableExpression} + */ + abstract function GetExpectedArguments(): array; } diff --git a/core/dbunionsearch.class.php b/core/dbunionsearch.class.php index 34ea4acf1..454333c94 100644 --- a/core/dbunionsearch.class.php +++ b/core/dbunionsearch.class.php @@ -1,21 +1,8 @@ - +/* + * @copyright Copyright (C) 2010-2023 Combodo SARL + * @license http://opensource.org/licenses/AGPL-3.0 + */ /** * A union of DBObjectSearches @@ -34,7 +21,6 @@ * @see DBSearch * @see DBObjectSearch */ - class DBUnionSearch extends DBSearch { protected $aSearches; // source queries @@ -676,26 +662,6 @@ class DBUnionSearch extends DBSearch return $oSQLQuery; } - function GetExpectedArguments() - { - $aVariableCriteria = array(); - foreach ($this->aSearches as $oSearch) - { - $aVariableCriteria = array_merge($aVariableCriteria, $oSearch->GetExpectedArguments()); - } - - return $aVariableCriteria; - } - /** - * @return \Expression - */ - public function GetCriteria() - { - // We're at the limit here - $oSearch = reset($this->aSearches); - return $oSearch->GetCriteria(); - } - protected function IsDataFiltered() { $bIsAllDataFiltered = true; @@ -738,13 +704,14 @@ class DBUnionSearch extends DBSearch } } - public function ListParameters() + function GetExpectedArguments(): array { - $aParameters = array(); + $aVariableCriteria = array(); foreach ($this->aSearches as $oSearch) { - $aParameters = array_merge($aParameters, $oSearch->ListParameters()); + $aVariableCriteria = array_merge($aVariableCriteria, $oSearch->GetExpectedArguments()); } - return $aParameters; + + return $aVariableCriteria; } } diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index 073d0fcad..78a9636dd 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -1,20 +1,7 @@ m_oNestedQuery->ListParameters(); + return $this->m_oNestedQuery->GetExpectedArguments(); } public function RenameParam($sOldName, $sNewName) { diff --git a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php index e3cf4fdb2..8301be02a 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php @@ -1,21 +1,8 @@ GetClass(); $aSearchParams = $oSearch->GetInternalParams();