Skip to content

Commit

Permalink
Fix: extrafield repair was using bad hardcoded values.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 23, 2012
1 parent 81be50b commit 1aa4429
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions htdocs/install/repair.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -211,12 +211,21 @@
$i=0; $i=0;
while($obj=$db->fetch_object($resql)) while($obj=$db->fetch_object($resql))
{ {
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname; $fieldname=$fieldtype='';
$fieldtype = isset($obj->Type)?$obj->Type:'varchar'; if (preg_match('/mysql/',$db->type))
{
$fieldname=$obj->Field;
$fieldtype=$obj->Type;
}
else
{
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
$fieldtype = isset($obj->Type)?$obj->Type:'varchar';
}


if (empty($fieldname)) continue; if (empty($fieldname)) continue;
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue; if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
$arrayoffieldsfound[$fieldname]=$fieldtype; $arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype);
} }


// If it does not match, we create fields // If it does not match, we create fields
Expand All @@ -225,14 +234,16 @@
if (! in_array($code,array_keys($arrayoffieldsfound))) if (! in_array($code,array_keys($arrayoffieldsfound)))
{ {
print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> ";
$type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null';
$field_desc=array( $field_desc=array(
'type'=>'varchar', 'type'=>$type,
'value'=>'', 'value'=>$value,
'attribute'=>'', 'attribute'=>$attribute,
'default'=>'', 'default'=>$default,
'extra'=>'', 'extra'=>$extra,
'null'=>'null' 'null'=>$null
); );
//var_dump($field_desc);exit;


$result=$db->DDLAddField($tableextra,$code,$field_desc,""); $result=$db->DDLAddField($tableextra,$code,$field_desc,"");
if ($result < 0) if ($result < 0)
Expand Down

0 comments on commit 1aa4429

Please sign in to comment.