diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index f3005f194..3406b51a8 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -1898,16 +1898,13 @@ class DBObjectSearch extends DBSearch // Hide objects that are not visible to the current user // $oSearch = $this; - if (!$this->IsAllDataAllowed() && !$this->IsDataFiltered()) - { + if (!$this->IsAllDataAllowed() && !$this->IsDataFiltered()) { $oVisibleObjects = UserRights::GetSelectFilter($this->GetClass(), $this->GetModifierProperties('UserRightsGetSelectFilter')); - if ($oVisibleObjects === false) - { + if ($oVisibleObjects === false) { // Make sure this is a valid search object, saying NO for all $oVisibleObjects = DBObjectSearch::FromEmptySet($this->GetClass()); } - if (is_object($oVisibleObjects)) - { + if (is_object($oVisibleObjects)) { $oVisibleObjects->AllowAllData(); $oSearch = $this->Intersect($oVisibleObjects); $oSearch->SetDataFiltered(); @@ -1927,63 +1924,49 @@ class DBObjectSearch extends DBSearch if (isset($_SERVER['REQUEST_URI'])) { $aContextData['sRequestUri'] = $_SERVER['REQUEST_URI']; - } - else if (isset($_SERVER['SCRIPT_NAME'])) - { + } else if (isset($_SERVER['SCRIPT_NAME'])) { $aContextData['sRequestUri'] = $_SERVER['SCRIPT_NAME']; - } - else - { + } else { $aContextData['sRequestUri'] = ''; } // Need to identify the query $sOqlQuery = $oSearch->ToOql(false, null, true); - if ((strpos($sOqlQuery, '`id` IN (') !== false) || (strpos($sOqlQuery, '`id` NOT IN (') !== false)) - { + if ((strpos($sOqlQuery, '`id` IN (') !== false) || (strpos($sOqlQuery, '`id` NOT IN (') !== false)) { // Requests containing "id IN" are not worth caching $bCanCache = false; } $aContextData['sOqlQuery'] = $sOqlQuery; - if (count($aModifierProperties)) - { + if (count($aModifierProperties)) { array_multisort($aModifierProperties); $sModifierProperties = json_encode($aModifierProperties); - } - else - { + } else { $sModifierProperties = ''; } $aContextData['sModifierProperties'] = $sModifierProperties; $sRawId = Dict::GetUserLanguage().'-'.$sOqlQuery.$sModifierProperties; - if (!is_null($aAttToLoad)) - { + if (!is_null($aAttToLoad)) { $sRawId .= json_encode($aAttToLoad); } $aContextData['aAttToLoad'] = $aAttToLoad; - if (!is_null($aGroupByExpr)) - { - foreach($aGroupByExpr as $sAlias => $oExpr) - { - $sRawId .= 'g:'.$sAlias.'!'.$oExpr->Render(); + if (!is_null($aGroupByExpr)) { + foreach ($aGroupByExpr as $sAlias => $oExpr) { + $sRawId .= 'g:'.$sAlias.'!'.$oExpr->RenderExpression(); } } - if (!is_null($aSelectExpr)) - { - foreach($aSelectExpr as $sAlias => $oExpr) - { - $sRawId .= 'se:'.$sAlias.'!'.$oExpr->Render(); + if (!is_null($aSelectExpr)) { + foreach ($aSelectExpr as $sAlias => $oExpr) { + $sRawId .= 'se:'.$sAlias.'!'.$oExpr->RenderExpression(); } } $aContextData['aGroupByExpr'] = $aGroupByExpr; $aContextData['aSelectExpr'] = $aSelectExpr; $sRawId .= $bGetCount; $aContextData['bGetCount'] = $bGetCount; - if (is_array($aSelectedClasses)) - { + if (is_array($aSelectedClasses)) { $sRawId .= implode(',', $aSelectedClasses); // Unions may alter the list of selected columns } $aContextData['aSelectedClasses'] = $aSelectedClasses; @@ -2094,17 +2077,13 @@ class DBObjectSearch extends DBSearch // 3rd step - position the attributes in the hierarchy of classes // $oSubClassExp->Browse(function($oNode) use ($sSubClass) { - if ($oNode instanceof FieldExpression) - { + if ($oNode instanceof FieldExpression) { $sAttCode = $oNode->GetName(); $oAttDef = MetaModel::GetAttributeDef($sSubClass, $sAttCode); - if ($oAttDef->IsExternalField()) - { + if ($oAttDef->IsExternalField()) { $sKeyAttCode = $oAttDef->GetKeyAttCode(); $sClassOfAttribute = MetaModel::GetAttributeOrigin($sSubClass, $sKeyAttCode); - } - else - { + } else { $sClassOfAttribute = MetaModel::GetAttributeOrigin($sSubClass, $sAttCode); } $sParent = MetaModel::GetAttributeOrigin($sClassOfAttribute, $oNode->GetName()); @@ -2112,12 +2091,11 @@ class DBObjectSearch extends DBSearch } }); - $sSignature = $oSubClassExp->Render(); - if (!array_key_exists($sSignature, $aExpressions)) - { + $sSignature = $oSubClassExp->RenderExpression(); + if (!array_key_exists($sSignature, $aExpressions)) { $aExpressions[$sSignature] = array( 'expression' => $oSubClassExp, - 'classes' => array(), + 'classes' => array(), ); } $aExpressions[$sSignature]['classes'][] = $sSubClass; diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index c7dd8493f..454c2c8ed 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -107,7 +107,7 @@ abstract class Expression { /** * recursive rendering * - * @deprecated use RenderExpression + * @deprecated 3.0.0 use RenderExpression * * @param array $aArgs used as input by default, or used as output if bRetrofitParams set to True * @param bool $bRetrofitParams @@ -118,7 +118,7 @@ abstract class Expression { public function Render(&$aArgs = null, $bRetrofitParams = false) { // cannot notify depreciation for now as this is still MASSIVELY used in iTop core ! - //DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use RenderExpression'); + DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use RenderExpression'); return $this->RenderExpression(false, $aArgs, $bRetrofitParams); } @@ -1765,6 +1765,7 @@ class FieldExpression extends UnaryExpression */ public function MakeValueLabel($oFilter, $sValue, $sDefault) { + $sAttCode = $this->GetName(); $sParentAlias = $this->GetParent(); @@ -3049,8 +3050,7 @@ class FunctionExpression extends Expression public function MakeValueLabel($oFilter, $sValue, $sDefault) { static $aWeekDayToString = null; - if (is_null($aWeekDayToString)) - { + if (is_null($aWeekDayToString)) { // Init the correspondance table $aWeekDayToString = array( 0 => Dict::S('DayOfWeek-Sunday'), @@ -3059,7 +3059,7 @@ class FunctionExpression extends Expression 3 => Dict::S('DayOfWeek-Wednesday'), 4 => Dict::S('DayOfWeek-Thursday'), 5 => Dict::S('DayOfWeek-Friday'), - 6 => Dict::S('DayOfWeek-Saturday') + 6 => Dict::S('DayOfWeek-Saturday'), ); } static $aMonthToString = null; @@ -3067,15 +3067,15 @@ class FunctionExpression extends Expression { // Init the correspondance table $aMonthToString = array( - 1 => Dict::S('Month-01'), - 2 => Dict::S('Month-02'), - 3 => Dict::S('Month-03'), - 4 => Dict::S('Month-04'), - 5 => Dict::S('Month-05'), - 6 => Dict::S('Month-06'), - 7 => Dict::S('Month-07'), - 8 => Dict::S('Month-08'), - 9 => Dict::S('Month-09'), + 1 => Dict::S('Month-01'), + 2 => Dict::S('Month-02'), + 3 => Dict::S('Month-03'), + 4 => Dict::S('Month-04'), + 5 => Dict::S('Month-05'), + 6 => Dict::S('Month-06'), + 7 => Dict::S('Month-07'), + 8 => Dict::S('Month-08'), + 9 => Dict::S('Month-09'), 10 => Dict::S('Month-10'), 11 => Dict::S('Month-11'), 12 => Dict::S('Month-12'), @@ -3083,30 +3083,25 @@ class FunctionExpression extends Expression } $sRes = $sDefault; - if (strtolower($this->m_sVerb) == 'date_format') - { + if (strtolower($this->m_sVerb) == 'date_format') { $oFormatExpr = $this->m_aArgs[1]; - if ($oFormatExpr->Render() == "'%w'") - { - if (isset($aWeekDayToString[(int)$sValue])) - { + //o + if ($oFormatExpr->RenderExpression() == "'%w'") { + if (isset($aWeekDayToString[(int)$sValue])) { $sRes = $aWeekDayToString[(int)$sValue]; } - } - elseif ($oFormatExpr->Render() == "'%Y-%m'") - { + } //o + elseif ($oFormatExpr->RenderExpression() == "'%Y-%m'") { // yyyy-mm => "yyyy month" - $iMonth = (int) substr($sValue, -2); // the two last chars + $iMonth = (int)substr($sValue, -2); // the two last chars $sRes = substr($sValue, 0, 4).' '.$aMonthToString[$iMonth]; - } - elseif ($oFormatExpr->Render() == "'%Y-%m-%d'") - { + } //o + elseif ($oFormatExpr->RenderExpression() == "'%Y-%m-%d'") { // yyyy-mm-dd => "month d" - $iMonth = (int) substr($sValue, 5, 2); + $iMonth = (int)substr($sValue, 5, 2); $sRes = $aMonthToString[$iMonth].' '.(int)substr($sValue, -2); - } - elseif ($oFormatExpr->Render() == "'%H'") - { + } //o + elseif ($oFormatExpr->RenderExpression() == "'%H'") { // H => "H Hour(s)" $sRes = $sValue.':00'; } diff --git a/test/replay_query_log.php b/test/replay_query_log.php index a2988a8ef..6d90f0b25 100644 --- a/test/replay_query_log.php +++ b/test/replay_query_log.php @@ -114,7 +114,7 @@ class QueryLogEntry $aGroupedBy = array(); foreach ($this->aGroupByExpr as $oExpr) { - $aGroupedBy[] = $oExpr->Render(); + $aGroupedBy[] = $oExpr->RenderExpression(); } $this->sQueryDesc = implode(', ', $aGroupedBy);