diff --git a/core/cmdbobject.class.inc.php b/core/cmdbobject.class.inc.php index dd3a47428..d722a9eef 100644 --- a/core/cmdbobject.class.inc.php +++ b/core/cmdbobject.class.inc.php @@ -75,82 +75,6 @@ require_once('cmdbchangeop.class.inc.php'); require_once('csvparser.class.inc.php'); require_once('bulkchange.class.inc.php'); - -// -// Error handling -// To be finalized... or removed ? -// -function cmdbErrorHandler($errno, $errstr, $errfile, $errline) -{ -// font-family: Courier-New, Courier, Arial, Helevtica; - $sErrorStyle = " - background-color: #ffaaaa; - color: #000000; - border: 1px dashed #000000; - padding: 0.25em; - margin-top: 1em; - "; - $sCallStackStyle = " - font-size: smaller; - background-color: #ffcccc; - color: #000000; - border: 1px dashed #000000; - padding: 0.25em; - margin-top: 1em; - "; - - switch ($errno) - { - case E_USER_ERROR: - case E_ERROR: - echo "
\n"; - echo "Error [$errno] $errstr
\n"; - echo "
\n"; - MyHelpers::dump_callstack(1); - echo "
\n"; - echo "Hereafter the biz model internals:
\n"; - echo "
\n";
-		MetaModel::static_var_dump();
-		echo "
\n"; - echo "Aborting...
\n"; - echo "
\n"; - exit(1); - break; - case E_USER_WARNING: - case E_WARNING: - echo "
\n"; - echo "Warning [$errno] $errstr
\n"; - echo "
\n"; - MyHelpers::dump_callstack(1); - echo "
\n"; - echo "
\n"; - break; - case E_USER_NOTICE: - case E_NOTICE: - echo "
\n"; - echo "Notice [$errno] $errstr
\n"; - echo "
\n"; - MyHelpers::dump_callstack(1); - echo "
\n"; - echo "
\n"; - break; - default: - echo "Unknown error type: [$errno] $errstr
\n"; - MyHelpers::dump_callstack(1); - break; - } -} - -error_reporting(E_ALL | E_STRICT); -//set_error_handler("cmdbErrorHandler"); - - - -// -// -// - - /** * A persistent object, which changes are accurately recorded * diff --git a/core/metamodel.class.php b/core/metamodel.class.php index be10e3331..c6f5247f7 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -2080,7 +2080,8 @@ abstract class MetaModel self::DbgTrace("External key $sKeyAttCode (class: $sKeyClass), call MakeQuery()"); $oSelectExtKey = self::MakeQuery($aSelectedClasses, $oConditionTree, $aClassAliases, $aTableAliases, $aTranslation, $oExtFilter, $aExpAtts); - $sLocalKeyField = current($oKeyAttDef->GetSQLExpressions()); // get the first column for an external key + $aCols = $oKeyAttDef->GetSQLExpressions(); // Workaround a PHP bug: sometimes issuing a Notice if invoking current(somefunc()) + $sLocalKeyField = current($aCols); // get the first column for an external key $sExternalKeyField = self::DBGetKey($sKeyClass); self::DbgTrace("External key $sKeyAttCode, Join on $sLocalKeyField = $sExternalKeyField"); if ($oKeyAttDef->IsNullAllowed()) @@ -2992,7 +2993,8 @@ abstract class MetaModel $sRemoteTable = self::DBGetTable($sRemoteClass); $sRemoteKey = self::DBGetKey($sRemoteClass); - $sExtKeyField = current($oAttDef->GetSQLExpressions()); // get the first column for an external key + $aCols = $oKeyAttDef->GetSQLExpressions(); // Workaround a PHP bug: sometimes issuing a Notice if invoking current(somefunc()) + $sExtKeyField = current($aCols); // get the first column for an external key // Note: a class/table may have an external key on itself $sSelBase = "SELECT DISTINCT maintable.`$sKeyField` AS id, maintable.`$sExtKeyField` AS extkey FROM `$sTable` AS maintable LEFT JOIN `$sRemoteTable` ON maintable.`$sExtKeyField` = `$sRemoteTable`.`$sRemoteKey`"; @@ -3038,7 +3040,8 @@ abstract class MetaModel { $sExpectedValues = implode(",", CMDBSource::Quote(array_keys($aAllowedValues), true)); - $sMyAttributeField = current($oAttDef->GetSQLExpressions()); // get the first column for the moment + $aCols = $oKeyAttDef->GetSQLExpressions(); // Workaround a PHP bug: sometimes issuing a Notice if invoking current(somefunc()) + $sMyAttributeField = current($aCols); // get the first column for the moment $sDefaultValue = $oAttDef->GetDefaultValue(); $sSelWrongRecs = "SELECT DISTINCT maintable.`$sKeyField` AS id FROM `$sTable` AS maintable WHERE maintable.`$sMyAttributeField` NOT IN ($sExpectedValues)"; self::DBCheckIntegrity_Check2Update($sSelWrongRecs, "Record having a column ('$sAttCode') with an unexpected value", $sMyAttributeField, CMDBSource::Quote($sDefaultValue), $sClass, $aErrorsAndFixes, $iNewDelCount, $aPlannedDel); diff --git a/pages/UI.php b/pages/UI.php index 91dd03543..00d23d984 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -1395,8 +1395,10 @@ EOF } } $oKPI->ComputeAndReport('GUI creation before output'); + ExecutionKPI::ReportStats(); - ////MetaModel::ShowQueryTrace(); + MetaModel::ShowQueryTrace(); + $oP->output(); } catch(CoreException $e) @@ -1411,15 +1413,22 @@ catch(CoreException $e) { if (MetaModel::IsValidClass('EventIssue')) { - $oLog = new EventIssue(); - - $oLog->Set('message', $e->getMessage()); - $oLog->Set('userinfo', ''); - $oLog->Set('issue', $e->GetIssue()); - $oLog->Set('impact', 'Page could not be displayed'); - $oLog->Set('callstack', $e->getTrace()); - $oLog->Set('data', $e->getContextData()); - $oLog->DBInsertNoReload(); + try + { + $oLog = new EventIssue(); + + $oLog->Set('message', $e->getMessage()); + $oLog->Set('userinfo', ''); + $oLog->Set('issue', $e->GetIssue()); + $oLog->Set('impact', 'Page could not be displayed'); + $oLog->Set('callstack', $e->getTrace()); + $oLog->Set('data', $e->getContextData()); + $oLog->DBInsertNoReload(); + } + catch(Exception $e) + { + IssueLog::Error("Failed to log issue into the DB"); + } } IssueLog::Error($e->getMessage()); @@ -1440,15 +1449,22 @@ catch(Exception $e) { if (MetaModel::IsValidClass('EventIssue')) { - $oLog = new EventIssue(); - - $oLog->Set('message', $e->getMessage()); - $oLog->Set('userinfo', ''); - $oLog->Set('issue', 'PHP Exception'); - $oLog->Set('impact', 'Page could not be displayed'); - $oLog->Set('callstack', $e->getTrace()); - $oLog->Set('data', array()); - $oLog->DBInsertNoReload(); + try + { + $oLog = new EventIssue(); + + $oLog->Set('message', $e->getMessage()); + $oLog->Set('userinfo', ''); + $oLog->Set('issue', 'PHP Exception'); + $oLog->Set('impact', 'Page could not be displayed'); + $oLog->Set('callstack', $e->getTrace()); + $oLog->Set('data', array()); + $oLog->DBInsertNoReload(); + } + catch(Exception $e) + { + IssueLog::Error("Failed to log issue into the DB"); + } } IssueLog::Error($e->getMessage());