Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into 8.0
Conflicts: htdocs/install/upgrade2.php
This commit is contained in:
commit
f747cefda3
@ -256,10 +256,10 @@ class ExtraFields
|
||||
if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255';
|
||||
}
|
||||
$field_desc = array(
|
||||
'type'=>$typedb,
|
||||
'value'=>$lengthdb,
|
||||
'null'=>($required?'NOT NULL':'NULL'),
|
||||
'default' => $default_value
|
||||
'type'=>$typedb,
|
||||
'value'=>$lengthdb,
|
||||
'null'=>($required?'NOT NULL':'NULL'),
|
||||
'default' => $default_value
|
||||
);
|
||||
|
||||
$result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
|
||||
@ -375,8 +375,8 @@ class ExtraFields
|
||||
$sql.= " '".$this->db->escape($list)."',";
|
||||
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . (is_object($user) ? $user->id : 0). ",";
|
||||
$sql .= " " . (is_object($user) ? $user->id : 0). ",";
|
||||
$sql .= "'" . $this->db->idate(dol_now()) . "',";
|
||||
$sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1");
|
||||
$sql.=')';
|
||||
|
||||
@ -765,28 +765,36 @@ class DoliDBMysqli extends DoliDB
|
||||
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
|
||||
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
|
||||
$sql.= $field_desc['type'];
|
||||
if(preg_match("/^[^\s]/i",$field_desc['value']))
|
||||
if (preg_match("/^[^\s]/i",$field_desc['value']))
|
||||
{
|
||||
if (! in_array($field_desc['type'],array('date','datetime')))
|
||||
{
|
||||
$sql.= "(".$field_desc['value'].")";
|
||||
}
|
||||
if(preg_match("/^[^\s]/i",$field_desc['attribute']))
|
||||
$sql.= " ".$field_desc['attribute'];
|
||||
if(preg_match("/^[^\s]/i",$field_desc['null']))
|
||||
$sql.= " ".$field_desc['null'];
|
||||
if(preg_match("/^[^\s]/i",$field_desc['default']))
|
||||
}
|
||||
if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i",$field_desc['attribute']))
|
||||
{
|
||||
$sql.= " ".$field_desc['attribute'];
|
||||
}
|
||||
if (isset($field_desc['null']) && preg_match("/^[^\s]/i",$field_desc['null']))
|
||||
{
|
||||
$sql.= " ".$field_desc['null'];
|
||||
}
|
||||
if (isset($field_desc['default']) && preg_match("/^[^\s]/i",$field_desc['default']))
|
||||
{
|
||||
if(preg_match("/null/i",$field_desc['default']))
|
||||
$sql.= " default ".$field_desc['default'];
|
||||
else
|
||||
$sql.= " default '".$field_desc['default']."'";
|
||||
}
|
||||
if(preg_match("/^[^\s]/i",$field_desc['extra']))
|
||||
$sql.= " ".$field_desc['extra'];
|
||||
if (isset($field_desc['extra']) && preg_match("/^[^\s]/i",$field_desc['extra']))
|
||||
{
|
||||
$sql.= " ".$field_desc['extra'];
|
||||
}
|
||||
$sql.= " ".$field_position;
|
||||
|
||||
dol_syslog(get_class($this)."::DDLAddField ".$sql,LOG_DEBUG);
|
||||
if($this->query($sql)) {
|
||||
if ($this->query($sql)) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*
|
||||
@ -21,10 +21,13 @@
|
||||
*
|
||||
* cd htdocs/install
|
||||
* php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion]
|
||||
* php upgrade2.php 3.4.0 3.5.0
|
||||
* php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE]
|
||||
*
|
||||
* Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line a script from a module.
|
||||
* Option 'ignoredbversion' allows to run migration even if database is a bugged database version.
|
||||
* And for final step:
|
||||
* php step5.php 3.4.0 3.5.0
|
||||
*
|
||||
* Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line using a script from a module.
|
||||
* Option 'ignoredbversion' allows to run migration even if database version does not match start version of migration
|
||||
* Return code is 0 if OK, >0 if error
|
||||
*/
|
||||
|
||||
@ -84,7 +87,7 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial
|
||||
if (! $versionfrom && ! $versionto)
|
||||
{
|
||||
print 'Error: Parameter versionfrom or versionto missing.'."\n";
|
||||
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n";
|
||||
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n";
|
||||
// Test if batch mode
|
||||
$sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
@ -18,13 +18,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Upgrade scripts can be ran from command line with syntax:
|
||||
* Upgrade2 scripts can be ran from command line with syntax:
|
||||
*
|
||||
* cd htdocs/install
|
||||
* php upgrade.php 3.4.0 3.5.0
|
||||
* php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE]
|
||||
* php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion]
|
||||
* php upgrade2.php 3.4.0 3.5.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE]
|
||||
*
|
||||
* And for final step:
|
||||
* php step5.php 3.4.0 3.5.0
|
||||
*
|
||||
* Return code is 0 if OK, >0 if error
|
||||
*
|
||||
* Note: To just enable a module from command line, use this syntax:
|
||||
* php upgrade2.php 0.0.0 0.0.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE]
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -77,7 +83,7 @@ if ($dolibarr_main_db_type == 'pgsql') $choix=2;
|
||||
if ($dolibarr_main_db_type == 'mssql') $choix=3;
|
||||
|
||||
|
||||
dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page");
|
||||
dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules);
|
||||
if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR);
|
||||
|
||||
|
||||
@ -89,14 +95,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial
|
||||
if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto)))
|
||||
{
|
||||
print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n";
|
||||
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n";
|
||||
print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\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";
|
||||
print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
@ -537,12 +543,12 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
|
||||
dolCopyDir($srcroot, $destroot, 0, 0);
|
||||
|
||||
|
||||
// Actions for all versions (no database change, delete files and directories)
|
||||
// Actions for all versions (no database change but delete some files and directories)
|
||||
migrate_delete_old_files($db, $langs, $conf);
|
||||
migrate_delete_old_dir($db, $langs, $conf);
|
||||
// Actions for all versions (no database change, create directories)
|
||||
// Actions for all versions (no database change but create some directories)
|
||||
dol_mkdir(DOL_DATA_ROOT.'/bank');
|
||||
// Actions for all versions (no database change, rename directories)
|
||||
// Actions for all versions (no database change but rename some directories)
|
||||
migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits');
|
||||
|
||||
print '<div><br>'.$langs->trans("MigrationFinished").'</div>';
|
||||
@ -4532,11 +4538,11 @@ function migrate_delete_old_dir($db,$langs,$conf)
|
||||
* @param int $force 1=Reload module even if not already loaded
|
||||
* @return void
|
||||
*/
|
||||
function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0)
|
||||
function migrate_reload_modules($db, $langs, $conf, $listofmodule=array(), $force=0)
|
||||
{
|
||||
if (count($listofmodule) == 0) return;
|
||||
|
||||
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force);
|
||||
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule)));
|
||||
|
||||
foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate'
|
||||
{
|
||||
@ -4719,8 +4725,15 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0)
|
||||
$tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg);
|
||||
if (! empty($reg[1]))
|
||||
{
|
||||
$moduletoreloadshort = ucfirst(strtolower($reg[1]));
|
||||
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort);
|
||||
if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase
|
||||
{
|
||||
$moduletoreloadshort = ucfirst(strtolower($reg[1]));
|
||||
}
|
||||
else // If key is a mix of up and low case
|
||||
{
|
||||
$moduletoreloadshort = $reg[1];
|
||||
}
|
||||
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode);
|
||||
$res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php';
|
||||
if ($res) {
|
||||
$classname = 'mod'.$moduletoreloadshort;
|
||||
@ -4728,10 +4741,27 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0)
|
||||
//$mod->remove('noboxes');
|
||||
$mod->init($reloadmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php');
|
||||
|
||||
$res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php');
|
||||
if ($res) {
|
||||
$classname = 'mod'.$moduletoreloadshort;
|
||||
$mod=new $classname($db);
|
||||
//$mod->remove('noboxes');
|
||||
$mod->init($reloadmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error, can't find module name";
|
||||
dolibarr_install_syslog("Error, can't find module with name ".$moduletoreload, LOG_WARNING);
|
||||
print "Error, can't find module with name ".$moduletoreload;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user