|
@@ -48,7 +48,8 @@ $versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($arg
|
|
|
$versionto=GETPOST("versionto",'',3)?GETPOST("versionto",'',3):(empty($argv[2])?'':$argv[2]);
|
|
|
|
|
|
$langs->load("admin");
|
|
|
-$langs->load("install");
|
|
|
+$langs->load("install");
|
|
|
+$langs->load("errors");
|
|
|
|
|
|
if ($dolibarr_main_db_type == "mysql") $choix=1;
|
|
|
if ($dolibarr_main_db_type == "mysqli") $choix=1;
|
|
@@ -152,79 +153,96 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
|
|
print '<tr><td>'.$langs->trans("ServerVersion").'</td>';
|
|
|
print '<td align="right">'.$version.'</td></tr>';
|
|
|
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");
|
|
|
- //print '<td align="right">'.join('.',$versionarray).'</td></tr>';
|
|
|
+
|
|
|
+ // Test database version
|
|
|
+ $versionmindb=getStaticMember(get_class($db),'versionmin');
|
|
|
+ //print join('.',$versionarray).' - '.join('.',$versionmindb);
|
|
|
+ if (count($versionmindb) && count($versionarray)
|
|
|
+ && versioncompare($versionarray,$versionmindb) < 0)
|
|
|
+ {
|
|
|
+ // Warning: database version too low.
|
|
|
+ print "<tr><td>".$langs->trans("ErrorDatabaseVersionTooLow",join('.',$versionarray),join('.',$versionmindb))."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>\n";
|
|
|
+ dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionTooLow",join('.',$versionarray),join('.',$versionmindb)));
|
|
|
+ $ok=0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// Force l'affichage de la progression
|
|
|
- print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
|
|
|
- flush();
|
|
|
-
|
|
|
+ if ($ok)
|
|
|
+ {
|
|
|
+ print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
|
|
|
+ flush();
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
* Delete duplicates in table categorie_association
|
|
|
*/
|
|
|
- $couples=array();
|
|
|
- $filles=array();
|
|
|
- $sql = "SELECT fk_categorie_mere, fk_categorie_fille";
|
|
|
- $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
|
|
|
- dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
|
|
|
- $resql = $db->query($sql);
|
|
|
- if ($resql)
|
|
|
- {
|
|
|
- $num=$db->num_rows($resql);
|
|
|
- while ($obj=$db->fetch_object($resql))
|
|
|
- {
|
|
|
- if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
|
|
|
- {
|
|
|
- if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
|
|
|
- {
|
|
|
- $filles[$obj->fk_categorie_fille]=1; // Set record for this child
|
|
|
- $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
|
|
|
-
|
|
|
- // If there is duplicates couples or child with two parents
|
|
|
- if (count($couples) > 0 && $num > count($couples))
|
|
|
- {
|
|
|
- $error=0;
|
|
|
-
|
|
|
- $db->begin();
|
|
|
-
|
|
|
- $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
|
|
|
- dolibarr_install_syslog("upgrade: delete association sql=".$sql);
|
|
|
- $resqld=$db->query($sql);
|
|
|
- if ($resqld)
|
|
|
- {
|
|
|
- foreach($couples as $key => $val)
|
|
|
- {
|
|
|
- $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
|
|
|
- $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
|
|
|
- dolibarr_install_syslog("upgrade: insert association sql=".$sql);
|
|
|
- $resqli=$db->query($sql);
|
|
|
- if (! $resqli) $error++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (! $error)
|
|
|
- {
|
|
|
- print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
|
|
|
- print '<td align="right">'.$langs->trans("Success").' ('.$num.'=>'.count($couples).')</td></tr>';
|
|
|
- $db->commit();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
|
|
|
- print '<td align="right">'.$langs->trans("Failed").'</td></tr>';
|
|
|
- $db->rollback();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if ($ok)
|
|
|
{
|
|
|
- print '<div class="error">'.$langs->trans("Error").'</div>';
|
|
|
+ $couples=array();
|
|
|
+ $filles=array();
|
|
|
+ $sql = "SELECT fk_categorie_mere, fk_categorie_fille";
|
|
|
+ $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
|
|
|
+ dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ if ($resql)
|
|
|
+ {
|
|
|
+ $num=$db->num_rows($resql);
|
|
|
+ while ($obj=$db->fetch_object($resql))
|
|
|
+ {
|
|
|
+ if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
|
|
|
+ {
|
|
|
+ if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
|
|
|
+ {
|
|
|
+ $filles[$obj->fk_categorie_fille]=1; // Set record for this child
|
|
|
+ $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
|
|
|
+
|
|
|
+ // If there is duplicates couples or child with two parents
|
|
|
+ if (count($couples) > 0 && $num > count($couples))
|
|
|
+ {
|
|
|
+ $error=0;
|
|
|
+
|
|
|
+ $db->begin();
|
|
|
+
|
|
|
+ $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
|
|
|
+ dolibarr_install_syslog("upgrade: delete association sql=".$sql);
|
|
|
+ $resqld=$db->query($sql);
|
|
|
+ if ($resqld)
|
|
|
+ {
|
|
|
+ foreach($couples as $key => $val)
|
|
|
+ {
|
|
|
+ $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
|
|
|
+ $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
|
|
|
+ dolibarr_install_syslog("upgrade: insert association sql=".$sql);
|
|
|
+ $resqli=$db->query($sql);
|
|
|
+ if (! $resqli) $error++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (! $error)
|
|
|
+ {
|
|
|
+ print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
|
|
|
+ print '<td align="right">'.$langs->trans("Success").' ('.$num.'=>'.count($couples).')</td></tr>';
|
|
|
+ $db->commit();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
|
|
|
+ print '<td align="right">'.$langs->trans("Failed").'</td></tr>';
|
|
|
+ $db->rollback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ print '<div class="error">'.$langs->trans("Error").'</div>';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -232,7 +250,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
|
|
*/
|
|
|
if ($ok && preg_match('/mysql/',$db->type))
|
|
|
{
|
|
|
- $versioncommande=explode('.','4.0');
|
|
|
+ $versioncommande=array(4,0,0);
|
|
|
if (count($versioncommande) && count($versionarray)
|
|
|
&& versioncompare($versioncommande,$versionarray) <= 0) // Si mysql >= 4.0
|
|
|
{
|