N°6442 - Error in Database integrity due to "translate placeholder in notification"

This commit is contained in:
Eric Espie
2023-06-27 15:23:28 +02:00
parent 98d4fa4331
commit 2c8db92504

View File

@@ -462,6 +462,11 @@ class DatabaseAnalyzer
$aCols = $oAttDef->GetSQLExpressions(); // Workaround a PHP bug: sometimes issuing a Notice if invoking current(somefunc())
$sMyAttributeField = current($aCols); // get the first column for the moment
$sFilter = "FROM `$sTable` WHERE `$sTable`.`$sMyAttributeField` NOT IN ($sExpectedValues)";
if ($oAttDef->IsNullAllowed()) {
$sSearchType = $oAttDef->GetSearchType();
$sCondition = $this->NotEmptyToSql("`$sTable`.`$sMyAttributeField`", $sSearchType);
$sFilter .= " AND $sCondition";
}
$sDelete = "DELETE `$sTable`";
$sSelect = "SELECT DISTINCT `$sTable`.`$sKeyField` AS id, `$sTable`.`$sMyAttributeField` AS value";
$sSelWrongRecs = "$sSelect $sFilter";
@@ -492,6 +497,19 @@ class DatabaseAnalyzer
}
}
private function NotEmptyToSql($sRef, $sSearchType)
{
switch ($sSearchType) {
case AttributeDefinition::SEARCH_WIDGET_TYPE_NUMERIC:
case AttributeDefinition::SEARCH_WIDGET_TYPE_EXTERNAL_FIELD:
case AttributeDefinition::SEARCH_WIDGET_TYPE_DATE:
case AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME:
return "ISNULL({$sRef}) = 0";
}
return "({$sRef} != '')";
}
/**
* Check user accounts without profile
*