N°2370 - Remove MySQL views in iTop, moved to "combodo-views" extension

This commit is contained in:
Eric
2020-07-08 10:33:15 +02:00
parent d73fdce3c5
commit 4f3931e828

View File

@@ -5646,32 +5646,9 @@ abstract class MetaModel
$sView = self::DBGetView($sClass);
if (CMDBSource::IsTable($sView))
{
// Check that the view is complete
//
// Note: checking the list of attributes is not enough because the columns can be stable while the SELECT is not stable
// Example: new way to compute the friendly name
// The correct comparison algorithm is to compare the queries,
// by using "SHOW CREATE VIEW" (MySQL 5.0.1 required) or to look into INFORMATION_SCHEMA/views
// both requiring some privileges
// Decision: to simplify, let's consider the views as being wrong anytime
// Rework the view
//
$oFilter = new DBObjectSearch($sClass, '');
$oFilter->AllowAllData();
$sSQL = $oFilter->MakeSelectQuery();
$aErrors[$sClass]['*'][] = "Redeclare view '$sView' (systematic - to support an eventual change in the friendly name computation)";
$aSugFix[$sClass]['*'][] = "ALTER VIEW `$sView` AS $sSQL";
}
else
{
// Create the view
//
$oFilter = new DBObjectSearch($sClass, '');
$oFilter->AllowAllData();
$sSQL = $oFilter->MakeSelectQuery();
$aErrors[$sClass]['*'][] = "Missing view for class: $sClass";
$aSugFix[$sClass]['*'][] = "DROP VIEW IF EXISTS `$sView`";
$aSugFix[$sClass]['*'][] = "CREATE VIEW `$sView` AS $sSQL";
// Remove deprecated views
$aErrors[$sClass]['*'][] = "Remove view '$sView' (deprecated, consider installing combodo-views if needed)";
$aSugFix[$sClass]['*'][] = "DROP VIEW `$sView`";
}
}
return array($aErrors, $aSugFix);