浏览代码

Fix: Usage of migration scripts from command line

Laurent Destailleur 10 年之前
父节点
当前提交
b68bfac593

+ 0 - 0
htdocs/install/mysql/migration/3.5.0-3.6.0.sql


+ 0 - 0
htdocs/install/mysql/migration/3.6.0-3.7.0.sql


+ 0 - 0
htdocs/install/mysql/migration/repair.sql


+ 17 - 6
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 '<h3>'.$langs->trans("DatabaseMigration").'</h3>';
 
-    if (! $versionfrom && ! $versionto)
-    {
-        print '<div class="error">Parameter versionfrom or versionto missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php</div>';
-        exit;
-    }
-
     print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
     $error=0;
 

+ 15 - 0
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);