From 1aa442977c69401c5523ff9bf0fb0e590002d381 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 May 2012 11:48:52 +0200 Subject: [PATCH] Fix: extrafield repair was using bad hardcoded values. --- htdocs/install/repair.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index cf6a5a830fb..7179f94efc1 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -211,12 +211,21 @@ foreach($listofmodulesextra as $tablename => $elementtype) $i=0; while($obj=$db->fetch_object($resql)) { - $fieldname = isset($obj->Key)?$obj->Key:$obj->attname; - $fieldtype = isset($obj->Type)?$obj->Type:'varchar'; + $fieldname=$fieldtype=''; + 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 (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 @@ -225,14 +234,16 @@ foreach($listofmodulesextra as $tablename => $elementtype) 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." -> "; + $type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null'; $field_desc=array( - 'type'=>'varchar', - 'value'=>'', - 'attribute'=>'', - 'default'=>'', - 'extra'=>'', - 'null'=>'null' + 'type'=>$type, + 'value'=>$value, + 'attribute'=>$attribute, + 'default'=>$default, + 'extra'=>$extra, + 'null'=>$null ); + //var_dump($field_desc);exit; $result=$db->DDLAddField($tableextra,$code,$field_desc,""); if ($result < 0)