Browse Source

Improved the column load optimization which was causing object reloads in various circumstances (impact can be important when loading lists with many lines):
1) When changing column settings (menu "Configure this list")
2) When a plugin was systematically reading some data (e.g. Highlighting late tickets requires to read tto/trr/status/start_date!)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2925 a333f486-631f-4898-b8df-5754b55c2be0

romainq 11 năm trước cách đây
mục cha
commit
638c1a6a00

+ 0 - 13
application/cmdbabstract.class.inc.php

@@ -818,9 +818,6 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 		$sClassAlias = $oSet->GetClassAlias();
 		$bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
 		
-		// Load only the requested columns
-		$oSet->OptimizeColumnLoad(array($sClassAlias => $aList));
-		
 		$sTableId = isset($aExtraParams['table_id']) ? $aExtraParams['table_id'] : null;
 		$aClassAliases = array( $sClassAlias => $sClassName);
 		$oDataTable = new DataTable($iListId, $oSet, $aClassAliases, $sTableId);
@@ -920,16 +917,6 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 				}
 			}						
 		}
-		// Load only the requested columns
-		$aAttToLoad = array(); // attributes to load
-		foreach($aAuthorizedClasses as $sAlias => $sClassName)
-		{
-			foreach($aList[$sAlias] as $sAttCode)
-			{
-				$aAttToLoad[$sAlias][] = $sAttCode;
-			}
-		}
-		$oSet->OptimizeColumnLoad($aAttToLoad);
 
 		$sSelectMode = 'none';
 				

+ 29 - 1
application/datatable.class.inc.php

@@ -75,7 +75,35 @@ class DataTable
 			$this->oSet->SetLimit($oCustomSettings->iDefaultPageSize);
 		}
 		$this->oSet->SetOrderBy($oCustomSettings->GetSortOrder());
-		
+
+		// Load only the requested columns
+		$aColumnsToLoad = array();
+		foreach($oCustomSettings->aColumns as $sAlias => $aColumnsInfo)
+		{
+			foreach($aColumnsInfo as $sAttCode => $aData)
+			{
+				if ($sAttCode != '_key_')
+				{
+					if ($aData['checked'])
+					{
+						$aColumnsToLoad[$sAlias][] = $sAttCode;
+					}
+					else
+					{
+						// See if this column is a must to load			
+						$sClass = $this->aClassAliases[$sAlias];
+						$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
+						if ($oAttDef->alwaysLoadInTables())
+						{
+							$aColumnsToLoad[$sAlias][] = $sAttCode;
+						}
+					}
+				}
+			}
+		}
+		$this->oSet->OptimizeColumnLoad($aColumnsToLoad);
+
+
 		$bToolkitMenu = true;
 		if (isset($aExtraParams['toolkit_menu']))
 		{

+ 1 - 0
core/attributedef.class.inc.php

@@ -210,6 +210,7 @@ abstract class AttributeDefinition
 	public function IsExternalField() {return false;} 
 	public function IsWritable() {return false;} 
 	public function LoadInObject() {return true;}
+	public function AlwaysLoadInTables() {return $this->GetOptional('always_load_in_tables', false);}
 	public function GetValue($oHostObject){return null;} // must return the value if LoadInObject returns false
 	public function IsNullAllowed() {return true;} 
 	public function GetCode() {return $this->m_sCode;} 

+ 3 - 0
datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml

@@ -37,6 +37,7 @@
       </properties>
       <fields>
         <field id="status" xsi:type="AttributeEnum">
+          <always_load_in_tables>true</always_load_in_tables>
           <values>
             <value>new</value>
             <value>assigned</value>
@@ -163,6 +164,7 @@
           <goal/>
         </field>
         <field id="tto" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>
@@ -189,6 +191,7 @@
           </thresholds>
         </field>
         <field id="ttr" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>

+ 3 - 0
datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml

@@ -37,6 +37,7 @@
       </properties>
       <fields>
         <field id="status" xsi:type="AttributeEnum">
+          <always_load_in_tables>true</always_load_in_tables>
           <values>
             <value>new</value>
             <value>waiting_for_approval</value>
@@ -188,6 +189,7 @@
           <goal/>
         </field>
         <field id="tto" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>
@@ -214,6 +216,7 @@
           </thresholds>
         </field>
         <field id="ttr" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>

+ 3 - 0
datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml

@@ -37,6 +37,7 @@
       </properties>
       <fields>
         <field id="status" xsi:type="AttributeEnum">
+          <always_load_in_tables>true</always_load_in_tables>
           <values>
             <value>new</value>
             <value>waiting_for_approval</value>
@@ -194,6 +195,7 @@
           <goal/>
         </field>
         <field id="tto" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>
@@ -220,6 +222,7 @@
           </thresholds>
         </field>
         <field id="ttr" xsi:type="AttributeStopWatch">
+          <always_load_in_tables>true</always_load_in_tables>
           <states>
             <state id="new"/>
             <state id="escalated_tto"/>

+ 1 - 0
datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml

@@ -99,6 +99,7 @@
           <is_null_allowed>false</is_null_allowed>
         </field>
         <field id="start_date" xsi:type="AttributeDateTime">
+          <always_load_in_tables>true</always_load_in_tables>
           <sql>start_date</sql>
           <default_value/>
           <is_null_allowed>true</is_null_allowed>

+ 1 - 0
setup/compiler.class.inc.php

@@ -878,6 +878,7 @@ EOF;
 			$aParameters['height'] = $this->GetPropNumber($oField, 'height');
 			$aParameters['digits'] = $this->GetPropNumber($oField, 'digits');
 			$aParameters['decimals'] = $this->GetPropNumber($oField, 'decimals');
+			$aParameters['always_load_in_tables'] = $this->GetPropBoolean($oField, 'always_load_in_tables', false);
 			$sTrackingLevel = $oField->GetChildText('tracking_level');
 			if (!is_null($sTrackingLevel))
 			{