From f03d731b1dfea6f14cd1e31b340815b3944c2abc Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 12 Jun 2024 16:14:23 +0200 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B07533=20-=20Prevent=20installation=20?= =?UTF-8?q?of=20iTop=20on=20Galera=20clusters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/cmdbsource.class.inc.php | 22 +++++++++++++++++----- setup/setuputils.class.inc.php | 8 ++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/core/cmdbsource.class.inc.php b/core/cmdbsource.class.inc.php index e65496cd0..5097c7538 100644 --- a/core/cmdbsource.class.inc.php +++ b/core/cmdbsource.class.inc.php @@ -95,7 +95,7 @@ class MySQLHasGoneAwayException extends MySQLException { return array( 2006, - 2013 + 2013, ); } @@ -1296,8 +1296,8 @@ class CMDBSource */ public static function IsSameFieldTypes($sItopGeneratedFieldType, $sDbFieldType) { - list($sItopFieldDataType, $sItopFieldTypeOptions, $sItopFieldOtherOptions) = static::GetFieldDataTypeAndOptions($sItopGeneratedFieldType); - list($sDbFieldDataType, $sDbFieldTypeOptions, $sDbFieldOtherOptions) = static::GetFieldDataTypeAndOptions($sDbFieldType); + [$sItopFieldDataType, $sItopFieldTypeOptions, $sItopFieldOtherOptions] = static::GetFieldDataTypeAndOptions($sItopGeneratedFieldType); + [$sDbFieldDataType, $sDbFieldTypeOptions, $sDbFieldOtherOptions] = static::GetFieldDataTypeAndOptions($sDbFieldType); if (strcasecmp($sItopFieldDataType, $sDbFieldDataType) !== 0) { @@ -1734,8 +1734,20 @@ class CMDBSource return false; } - /** - * @return string query to upgrade database charset and collation if needed, null if not + public static function GetClusterNb() + { + $result = 0; + $sSql = "SHOW STATUS LIKE 'wsrep_cluster_size';"; + $aRows = self::QueryToArray($sSql); + if (count($aRows) > 0) + { + $result = $aRows[0]['Value']; + } + return intval($result); + } + + /** + * @return string query to upgrade database charset and collation if needed, null if not * @throws \MySQLException * * @since 2.5.0 N°1001 switch to utf8mb4 diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 329a6b9f8..318dbc6ad 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -1230,6 +1230,12 @@ EOF $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_connections is set to $iMaxConnections."); } + $iClusters = $oDBSource->GetClusterNb(); + if ($iClusters > 0) { + SetupLog::Warning('Warning - Galera can lead to malfunctions and data corruption. Combodo does not support this type of infrastructure.'); + $aResult['checks'][] = new CheckResult(CheckResult::WARNING, 'Galera can lead to malfunctions and data corruption. Combodo does not support this type of infrastructure.'); + } + try { $aResult['databases'] = $oDBSource->ListDB(); } @@ -1345,6 +1351,8 @@ EOF static public function AsyncCheckDB($oPage, $aParameters) { + SetupPage::log('Info - CheckDB'); + $sDBServer = $aParameters['db_server']; $sDBUser = $aParameters['db_user']; $sDBPwd = $aParameters['db_pwd']; From 320922a13d1db48b68a508d5ee0d8695ea86d42a Mon Sep 17 00:00:00 2001 From: Timothee Date: Mon, 17 Jun 2024 16:49:33 +0200 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B07545=20Correctly=20display=20error?= =?UTF-8?q?=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2.x/itop-portal-base/portal/templates/layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig index 781e7c3fa..ccb0ee2d3 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig @@ -464,8 +464,8 @@ sBody = '{{ 'Error:XHR:Fail'|dict_format(constant('ITOP_APPLICATION_SHORT'))|escape('js') }}'; } var oModalElem = $('#modal-for-alert'); - oModalElem.find('.modal-content .modal-header .modal-title').html(sTitle); - oModalElem.find('.modal-content .modal-body .alert').addClass('alert-danger').html(sBody); + oModalElem.find('.modal-content .modal-header .modal-title').text(sTitle); + oModalElem.find('.modal-content .modal-body .alert').addClass('alert-danger').text(sBody); oModalElem.modal('show'); }; {% endblock %}