diff --git a/core/config.class.inc.php b/core/config.class.inc.php index fc8f20f29e..7c2c98d0a4 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -127,8 +127,9 @@ class Config ); $this->m_aDictionaries = array( // Default dictionaries, always present can be moved to an official iTop Module later if needed - '../dictionaries/dictionary.itop.core.php', - '../dictionaries/dictionary.itop.ui.php', + //'../dictionaries/dictionary.itop.core.php', + '../dictionaries/dictionary.itop.ui.php', // Support for English + '../dictionaries/fr.dictionary.itop.ui.php', // Support for French ); $this->m_sDBHost = ''; diff --git a/core/metamodel.class.php b/core/metamodel.class.php index fa1e1eb47e..dff74dd302 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -1448,7 +1448,17 @@ abstract class MetaModel $sOqlQuery = $oFilter->ToOql($aParams); // Render with arguments in clear if ($bQueryCacheEnabled) { - if (array_key_exists($sOqlQuery, self::$m_aQueryStructCache)) + // Warning: using directly the query string as the key to the hash array can FAIL if the string + // is long and the differences are only near the end... so it's safer (but not bullet proof?) + // to use a hash (like md5) of the string as the key ! + // + // Example of two queries that were found as similar by the hash array: + // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = 1 AND SLA.service_id = 3 AND SLT.metric = 'TTO' AND CustomerContract.customer_id = 2 + // and + // SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = 1 AND SLA.service_id = 3 AND SLT.metric = 'TTR' AND CustomerContract.customer_id = 2 + // the only difference is R instead or O at position 285 (TTR instead of TTO)... + // + if (array_key_exists(md5($sOqlQuery), self::$m_aQueryStructCache)) { // hit! $oSelect = clone self::$m_aQueryStructCache[$sOqlQuery]; @@ -3028,9 +3038,9 @@ abstract class MetaModel public static function Startup($sConfigFile, $bAllowMissingDB = false) { self::LoadConfig($sConfigFile); - //if (self::DBExists()) + if (self::DBExists()) // !!!! #@# - if (true) + //if (true) { CMDBSource::SelectDB(self::$m_sDBName); diff --git a/modules/itop-tickets-1.0.0/model.itop-tickets.php b/modules/itop-tickets-1.0.0/model.itop-tickets.php index a9e8d01513..2050571b7b 100644 --- a/modules/itop-tickets-1.0.0/model.itop-tickets.php +++ b/modules/itop-tickets-1.0.0/model.itop-tickets.php @@ -45,7 +45,7 @@ abstract class Ticket extends cmdbAbstractObject MetaModel::Init_AddAttribute(new AttributeString("ref", array("allowed_values"=>null, "sql"=>"ref", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeString("title", array("allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); -// MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeText("ticket_log", array("allowed_values"=>null, "sql"=>"ticket_log", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeDateTime("start_date", array("allowed_values"=>null, "sql"=>"start_date", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("document_list", array("linked_class"=>"lnkTicketToDoc", "ext_key_to_me"=>"ticket_id", "ext_key_to_remote"=>"document_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array()))); @@ -341,6 +341,7 @@ abstract class ResponseTicket extends Ticket { $sOQL = "SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id WHERE SLT.ticket_priority = :priority AND SLA.service_id = :service_id AND SLT.metric = :metric AND CustomerContract.customer_id = :customer_id"; + $oSLTSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array( @@ -356,8 +357,9 @@ abstract class ResponseTicket extends Ticket while($oSLT = $oSLTSet->Fetch()) { - $iDuration = $oSLT->Get('value'); + $iDuration = (int)$oSLT->Get('value'); $sUnit = $oSLT->Get('value_unit'); + //echo "
Found SLT: ".$oSLT->GetName()." - $iDuration ($sUnit)
\n"; switch($sUnit) { case 'days': @@ -383,7 +385,7 @@ abstract class ResponseTicket extends Ticket } else { - array('SLT' => $sSLTName, 'value' => $iMinDuration); + $aResult = array('SLT' => $sSLTName, 'value' => $iMinDuration); } } return $aResult;