1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 04:10:38 +02:00

Fixes #4268 - missing field in table definition. Tests added.

This commit is contained in:
Cameron
2020-11-29 14:05:14 -08:00
parent 35ad3e7284
commit 072c1b3a90
4 changed files with 480 additions and 118 deletions

View File

@@ -1093,7 +1093,7 @@ class e_db_mysql implements e_db
case 'array':
if(is_array($fieldValue))
{
return "'".e107::getArrayStorage()->writeArray($fieldValue, true)."'";
return "'".e107::getArrayStorage()->WriteArray($fieldValue, true)."'";
}
return "'". (string) $fieldValue."'";
break;
@@ -2565,59 +2565,8 @@ class e_db_mysql implements e_db
$fieldDefs = $dbAdm->parse_field_defs($baseStruct); // Required definitions
if (!$fieldDefs) return false;
$outDefs = array();
$outDefs = $dbAdm->make_field_types($fieldDefs);
foreach ($fieldDefs as $k => $v)
{
switch ($v['type'])
{
case 'field' :
if (vartrue($v['autoinc']))
{
//break; Probably include autoinc fields in array
}
$baseType = preg_replace('#\(\d+?\)#', '', $v['fieldtype']); // Should strip any length
switch ($baseType)
{
case 'int' :
case 'integer':
case 'shortint' :
case 'tinyint' :
case 'mediumint':
$outDefs['_FIELD_TYPES'][$v['name']] = 'int';
break;
case 'char' :
case 'text' :
case 'varchar' :
case 'tinytext' :
case 'mediumtext' :
case 'longtext' :
$outDefs['_FIELD_TYPES'][$v['name']] = 'escape'; //XXX toDB() causes serious BC issues.
break;
}
// if($v['name'])
if (isset($v['nulltype']) && !isset($v['default']))
{
$outDefs['_NOTNULL'][$v['name']] = '';
}
break;
case 'pkey' :
case 'ukey' :
case 'key' :
case 'ftkey' :
break; // Do nothing with keys for now
default :
echo "Unexpected field type: {$k} => {$v['type']}<br />";
}
}
// $array = e107::getArrayStorage();
$this->dbFieldDefs[$tableName] = $outDefs;
$toSave = e107::serialize($outDefs, false); // 2nd parameter to TRUE if needs to be written to DB