From 1f11dcb4bd1190746a3631c8571707de2bc33e0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Oct 2017 17:21:18 +0200 Subject: [PATCH] Fix no loose of configuration of action auto after upgrade Close #7527 --- htdocs/admin/agenda.php | 3 +- htdocs/core/modules/DolibarrModules.class.php | 2 +- htdocs/install/upgrade2.php | 33 ++++--------------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 50676e4c3af..cd07b4db587 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -80,8 +80,7 @@ if ($action == "save" && empty($cancel)) { $param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; //print "param=".$param." - ".$_POST[$param]; - if (GETPOST($param,'alpha')) $res = dolibarr_set_const($db,$param,GETPOST($param,'alpha'),'chaine',0,'',$conf->entity); - else $res = dolibarr_del_const($db,$param,$conf->entity); + $res = dolibarr_set_const($db,$param,(GETPOST($param,'alpha')?GETPOST($param,'alpha'):''),'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index bdf8effe23c..b11389905a4 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -406,7 +406,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! $err) $err+=$this->insert_module_parts(); // Insert constant defined by modules (into llx_const) - if (! $err) $err+=$this->insert_const(); + if (! $err && ! preg_match('/newboxdefonly/',$options)) $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) if (! $err && ! preg_match('/noboxes/',$options)) $err+=$this->insert_boxes($options); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 135d4b83caa..f6a51657799 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -410,15 +410,16 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 migrate_reload_menu($db,$langs,$conf,$versionto); } - // Can force activation of some module during migration with paramater 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' + // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' + // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. if (! $error && $enablemodules) { - // Reload modules (this must be always and only into last targeted version) + // Reload modules (this must be always done and only into last targeted version) $listofmodules=array(); $tmplistofmodules=explode(',', $enablemodules); foreach($tmplistofmodules as $value) { - $listofmodules[$value]='newboxdefonly'; + $listofmodules[$value]='forceactivate'; } migrate_reload_modules($db,$langs,$conf,$listofmodules,1); } @@ -4118,31 +4119,11 @@ function migrate_delete_old_dir($db,$langs,$conf) */ 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); - // If no info is provided, we reload all modules with mode newboxdefonly. - if (count($listofmodule) == 0) - { - $listofmodule=array( - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', - 'MAIN_MODULE_SALARIES'=>'newboxdefonly' - ); - } - - foreach($listofmodule as $moduletoreload => $reloadmode) + foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled