Skip to content
Snippets Groups Projects
Commit 70c4f0bd authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Can fix some fatal errors with a repair script.

parent b96f5017
Branches
Tags
Loading
......@@ -42,6 +42,7 @@ For developers:
- Updated wiki documentation.
- Better W3C standard.
- Can add data provided with a module.
- Can fix some corruptions in database by calling the update page with action=repair
***** Changelog for 2.6 compared to 2.5 *****
......
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -19,9 +19,10 @@
*/
/**
\file htdocs/install/upgrade.php
\brief Run migration script
\version $Id$
* \file htdocs/install/upgrade.php
* \brief Run migration script
* \version $Id$
* \remarks Can be also called directly with http://mydolibarr/install/upgrade.php?action=repair
*/
include_once("./inc.php");
......@@ -60,14 +61,22 @@ dolibarr_install_syslog("upgrade: Entering upgrade.php page");
if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized",LOG_ERR);
/*
* View
*/
pHeader($langs->trans("DatabaseMigration"),"upgrade2","upgrade");
$actiondone=0;
if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
// Action to launch the repair or migrate script
if (! isset($_GET["action"]) || $_GET["action"] == "upgrade" || $_GET["action"] == "repair")
{
$actiondone=1;
print '<h3>'.$langs->trans("DatabaseMigration").'<h3>';
if (! $versionfrom && ! $versionto)
if ($_GET["action"] != "repair" && ! $versionfrom && ! $versionto)
{
print '<div class="error">Parameter versionfrom or version to missing.</div>';
exit;
......@@ -138,7 +147,12 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
flush();
// Delete duplicates in table categorie_association
if ($_GET["action"] != "repair")
{
/*
* Delete duplicates in table categorie_association
*/
$couples=array();
$filles=array();
$sql = "SELECT fk_categorie_mere, fk_categorie_fille";
......@@ -203,7 +217,9 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
print '<div class="error">'.$langs->trans("Error").'</div>';
}
/*
* Remove deprecated indexes and constraints
*/
if ($ok)
{
$versioncommande=split('\.','4.0');
......@@ -257,12 +273,11 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
}
}
}
}
/***************************************************************************************
*
* Chargement fichiers dans migration
*
***************************************************************************************/
/*
* Load sql files
*/
if ($ok)
{
if ($choix==1) $dir = "../../mysql/migration/";
......@@ -284,7 +299,9 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
}
sort($filesindir);
# Determine les fichiers sql a passer
# Define which file to run
if ($_GET["action"] != "repair")
{
foreach($filesindir as $file)
{
if (eregi($from,$file))
......@@ -296,6 +313,17 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
$filelist[]=$file;
}
}
}
else
{
foreach($filesindir as $file)
{
if (eregi('repair',$file))
{
$filelist[]=$file;
}
}
}
# Boucle sur chaque fichier
foreach($filelist as $file)
......@@ -314,7 +342,9 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
if ($db->connected) $db->close();
}
else
if (empty($actiondone))
{
print '<div class="error">'.$langs->trans("ErrorWrongParameters").'</div>';
}
......
......@@ -172,8 +172,3 @@ alter table llx_commande_fournisseur add column ref_supplier varchar(30
alter table llx_mailing add column bgcolor varchar(8) after body;
alter table llx_mailing add column bgimage varchar(255) after bgcolor;
-- Request to clean corrupted database
delete from llx_facture where facnumber = '(PROV)';
delete from llx_commande where ref = '(PROV)';
delete from llx_propal where ref = '(PROV)';
--
-- $Id$
--
-- Script to repair some fatal errors due to database corruption
--
-- when current version is 2.6.0 or higher.
--
-- Request to clean corrupted database
delete from llx_facture where facnumber = '(PROV)';
delete from llx_commande where ref = '(PROV)';
delete from llx_propal where ref = '(PROV)';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment