From b68bfac593a7f33edfe72f390ea4d557ef0580a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 Nov 2014 13:46:12 +0100 Subject: [PATCH] Fix: Usage of migration scripts from command line --- .../install/mysql/migration/3.5.0-3.6.0.sql | 0 .../install/mysql/migration/3.6.0-3.7.0.sql | 0 htdocs/install/mysql/migration/repair.sql | 0 htdocs/install/upgrade.php | 23 ++++++++++++++----- htdocs/install/upgrade2.php | 15 ++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) mode change 100644 => 100755 htdocs/install/mysql/migration/3.5.0-3.6.0.sql mode change 100644 => 100755 htdocs/install/mysql/migration/3.6.0-3.7.0.sql mode change 100644 => 100755 htdocs/install/mysql/migration/repair.sql mode change 100644 => 100755 htdocs/install/upgrade.php mode change 100644 => 100755 htdocs/install/upgrade2.php diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql old mode 100644 new mode 100755 diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql old mode 100644 new mode 100755 diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql old mode 100644 new mode 100755 diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php old mode 100644 new mode 100755 index d89596e25e6..396c9f96b01 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -50,6 +50,7 @@ error_reporting(0); @set_time_limit(120); error_reporting($err); + $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto'; $langs->setDefaultLang($setuplang); $versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($argv[1])?'':$argv[1]); @@ -74,6 +75,22 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial * View */ +if (! $versionfrom && ! $versionto) +{ + print 'Error: Parameter versionfrom or versionto missing.'."\n"; + print 'Upgrade must be ran from cmmand line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + // Test if batch mode + $sapi_type = php_sapi_name(); + $script_file = basename(__FILE__); + $path=dirname(__FILE__).'/'; + if (substr($sapi_type, 0, 3) == 'cli') + { + print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; + } + exit; +} + + pHeader('',"upgrade2",GETPOST('action'),'versionfrom='.$versionfrom.'&versionto='.$versionto); $actiondone=0; @@ -85,12 +102,6 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) print '

'.$langs->trans("DatabaseMigration").'

'; - if (! $versionfrom && ! $versionto) - { - print '
Parameter versionfrom or versionto missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php
'; - exit; - } - print ''; $error=0; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php old mode 100644 new mode 100755 index 0bf76c7d729..3a02a78f9e8 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -83,6 +83,21 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial * View */ +if (! $versionfrom && ! $versionto) +{ + print 'Error: Parameter versionfrom or versionto missing.'."\n"; + print 'Upgrade must be ran from cmmand line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + // Test if batch mode + $sapi_type = php_sapi_name(); + $script_file = basename(__FILE__); + $path=dirname(__FILE__).'/'; + if (substr($sapi_type, 0, 3) == 'cli') + { + print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; + } + exit; +} + pHeader('','etape5',GETPOST("action")?GETPOST("action"):'upgrade','versionfrom='.$versionfrom.'&versionto='.$versionto);