diff --git a/datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php b/datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php index 6a3162a92..61330725a 100644 --- a/datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php +++ b/datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php @@ -128,10 +128,7 @@ class DatabaseAnalyzer foreach($aClassSelection as $sClass) { // Check uniqueness rules - if (method_exists('MetaModel', 'GetUniquenessRules')) - { - $this->CheckUniquenessRules($sClass, $aErrorsAndFixes); - } + $this->CheckUniquenessRules($sClass, $aErrorsAndFixes); if (!MetaModel::HasTable($sClass)) { @@ -151,6 +148,10 @@ class DatabaseAnalyzer $this->CheckRecordsInRootTable($sTable, $sKeyField, $sRootTable, $sRootKey, $sClass, $aErrorsAndFixes); $this->CheckRecordsInChildTable($sRootClass, $sClass, $sRootTable, $sRootKey, $sTable, $sKeyField, $aErrorsAndFixes); + if (!MetaModel::IsLeafClass($sClass)) + { + $this->CheckFinalClass($sRootClass, $sClass, $sRootTable, $sRootKey, $sTable, $sKeyField, $aErrorsAndFixes); + } } } @@ -317,6 +318,34 @@ class DatabaseAnalyzer $this->ExecQuery($sSelWrongRecs, $sFixItRequest, Dict::Format('DBAnalyzer-Integrity-OrphanRecord', $sRootTable, $sTable), $sRootClass, $aErrorsAndFixes); } + /** + * Check that the "finalclass" field is correct for all the classes of the hierarchy + * + * @param $sRootClass + * @param $sClass + * @param $sRootTable + * @param $sRootKey + * @param $sTable + * @param $sKeyField + * @param $aErrorsAndFixes + * + * @throws \CoreException + */ + private function CheckFinalClass($sRootClass, $sClass, $sRootTable, $sRootKey, $sTable, $sKeyField, &$aErrorsAndFixes) + { + $sField = MetaModel::DBGetClassField($sClass); + $sRootField = MetaModel::DBGetClassField($sRootClass); + $sSelWrongRecs = <<ExecQuery($sSelWrongRecs, $sFixItRequest, Dict::Format('DBAnalyzer-Integrity-FinalClass', $sField, $sTable, $sRootTable), $sClass, $aErrorsAndFixes); + } + /** * Check that any external field is pointing to an existing object * diff --git a/datamodels/2.x/combodo-db-tools/en.dict.combodo-db-tools.php b/datamodels/2.x/combodo-db-tools/en.dict.combodo-db-tools.php index ddad8345c..91e83d5d1 100644 --- a/datamodels/2.x/combodo-db-tools/en.dict.combodo-db-tools.php +++ b/datamodels/2.x/combodo-db-tools/en.dict.combodo-db-tools.php @@ -52,6 +52,7 @@ Dict::Add('EN US', 'English', 'English', array( 'DBAnalyzer-Integrity-InvalidValue' => 'Invalid value for %1$s (column: `%2$s.%3$s`)', 'DBAnalyzer-Integrity-UsersWithoutProfile' => 'Some user accounts have no profile at all', 'DBAnalyzer-Fetch-Count-Error' => 'Fetch count error in `%1$s`, %2$d entries fetched / %3$d counted', + 'DBAnalyzer-Integrity-FinalClass' => 'Field `%2$s`.`%1$s` must have the same value than `%3$s`.`%1$s`', )); // Database Info diff --git a/datamodels/2.x/combodo-db-tools/fr.dict.combodo-db-tools.php b/datamodels/2.x/combodo-db-tools/fr.dict.combodo-db-tools.php index 6a2bb8fed..d109626af 100644 --- a/datamodels/2.x/combodo-db-tools/fr.dict.combodo-db-tools.php +++ b/datamodels/2.x/combodo-db-tools/fr.dict.combodo-db-tools.php @@ -47,6 +47,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'DBAnalyzer-Integrity-InvalidValue' => 'Valeur invalide pour %1$s (colonne: `%2$s.%3$s`)', 'DBAnalyzer-Integrity-UsersWithoutProfile' => 'Certains comptes utilisateurs n\'ont aucun profile', 'DBAnalyzer-Fetch-Count-Error' => 'Erreur de récupération dans `%1$s`, %2$d enregistrements récupérés / %3$d comptés', + 'DBAnalyzer-Integrity-FinalClass' => 'Le champ `%2$s`.`%1$s` doit avoir la même valeur que `%3$s`.`%1$s`', )); // Database Info