mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Table names and DB prefix may have upper case letters, it should work -test on Windows where the actual name is transformed into lower case
SVN:code[28]
This commit is contained in:
@@ -64,9 +64,12 @@ class CMDBSource
|
||||
try
|
||||
{
|
||||
$aDBs = self::ListDB();
|
||||
// Show Database does return the DB names in lower case
|
||||
$sSourceRef = strtolower($sSource);
|
||||
return (in_array($sSourceRef, $aDBs));
|
||||
foreach($aDBs as $sDBName)
|
||||
{
|
||||
// perform a case insensitive test because on Windows the table names become lowercase :-(
|
||||
if (strtolower($sDBName) == strtolower($sSource)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
@@ -395,11 +398,14 @@ class CMDBSource
|
||||
{
|
||||
self::_TablesInfoCacheInit();
|
||||
|
||||
// table names are transformed into lower case
|
||||
// is that 100% specific to innodb and myISAM?
|
||||
$sTableLC = strtolower($sTable);
|
||||
|
||||
if (array_key_exists($sTableLC, self::$m_aTablesInfo)) return self::$m_aTablesInfo[$sTableLC];
|
||||
// perform a case insensitive match because on Windows the table names become lowercase :-(
|
||||
foreach(self::$m_aTablesInfo as $sTableName => $aInfo)
|
||||
{
|
||||
if (strtolower($sTableName) == strtolower($sTable))
|
||||
{
|
||||
return $aInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,8 +755,7 @@ abstract class MetaModel
|
||||
return;
|
||||
}
|
||||
|
||||
// Table names must be lower case
|
||||
self::$m_sTablePrefix = strtolower($sTablePrefix);
|
||||
self::$m_sTablePrefix = $sTablePrefix;
|
||||
|
||||
foreach(get_declared_classes() as $sPHPClass) {
|
||||
if (is_subclass_of($sPHPClass, 'DBObject'))
|
||||
@@ -1611,20 +1610,6 @@ abstract class MetaModel
|
||||
{
|
||||
if (self::IsAbstract($sClass)) continue;
|
||||
|
||||
// Check that SQL names are lower case (case is forced lowercase in the DB)
|
||||
$sTable = self::DBGetTable($sClass);
|
||||
$sKeyField = self::DBGetKey($sClass);
|
||||
if (!Str::islowcase($sTable))
|
||||
{
|
||||
$aErrors[$sClass][] = "Table name must be lower case (current value is '$sTable')";
|
||||
$aSugFix[$sClass][] = "";
|
||||
}
|
||||
//if (!Str::islowcase($sKeyField))
|
||||
//{
|
||||
// $aErrors[$sClass][] = "Table name must be lower case (current value is '$sKeyField')";
|
||||
// $aSugFix[$sClass][] = "";
|
||||
//}
|
||||
|
||||
$sNameAttCode = self::GetNameAttributeCode($sClass);
|
||||
if (empty($sNameAttCode))
|
||||
{
|
||||
@@ -1860,7 +1845,8 @@ abstract class MetaModel
|
||||
CMDBSource::SelectDB(self::$m_sDBName);
|
||||
foreach (CMDBSource::EnumTables() as $sTable)
|
||||
{
|
||||
if (substr($sTable, 0, strlen(self::$m_sTablePrefix)) == self::$m_sTablePrefix) return true;
|
||||
// perform a case insensitive test because on Windows the table names become lowercase :-(
|
||||
if (strtolower(substr($sTable, 0, strlen(self::$m_sTablePrefix))) == strtolower(self::$m_sTablePrefix)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1875,7 +1861,8 @@ abstract class MetaModel
|
||||
// then possibly drop the DB itself (if no table remain)
|
||||
foreach (CMDBSource::EnumTables() as $sTable)
|
||||
{
|
||||
if (substr($sTable, 0, strlen(self::$m_sTablePrefix)) == self::$m_sTablePrefix)
|
||||
// perform a case insensitive test because on Windows the table names become lowercase :-(
|
||||
if (strtolower(substr($sTable, 0, strlen(self::$m_sTablePrefix))) == strtolower(self::$m_sTablePrefix))
|
||||
{
|
||||
CMDBSource::DropTable($sTable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user