From 812687e10c0327fc819f6e682c225434484951ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Oct 2017 16:08:52 +0200 Subject: [PATCH] FIX Restore feature to enable a module during CLI upgrade --- .travis.yml | 6 ++-- htdocs/core/modules/DolibarrModules.class.php | 2 +- htdocs/install/upgrade2.php | 29 ++++++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d66915eb44b..ad8eb84a225 100644 --- a/.travis.yml +++ b/.travis.yml @@ -313,13 +313,13 @@ script: php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log - php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade400500-2.log + php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log - php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log + php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log - php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE > $TRAVIS_BUILD_DIR/upgrade600700-2.log php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log cd - set +e diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index c42fabcc937..16a1ef01bc5 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1843,7 +1843,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $menu->langs=$this->menu[$key]['langs']; $menu->position=$this->menu[$key]['position']; $menu->perms=$this->menu[$key]['perms']; - $menu->target=$this->menu[$key]['target']; + $menu->target=isset($this->menu[$key]['target'])?$this->menu[$key]['target']:''; $menu->user=$this->menu[$key]['user']; $menu->enabled=isset($this->menu[$key]['enabled'])?$this->menu[$key]['enabled']:0; $menu->position=$this->menu[$key]['position']; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f6a51657799..f273474ab09 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -61,11 +61,11 @@ error_reporting(0); @set_time_limit(300); error_reporting($err); -$setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto'; +$setuplang=GETPOST("selectlang",'alpha',3)?GETPOST("selectlang",'alpha',3):'auto'; $langs->setDefaultLang($setuplang); -$versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($argv[1])?'':$argv[1]); -$versionto=GETPOST("versionto",'',3)?GETPOST("versionto",'',3):(empty($argv[2])?'':$argv[2]); -$enablemodules=GETPOST("enablemodules",'',3)?GETPOST("enablemodules",'',3):(empty($argv[3])?'':$argv[3]); +$versionfrom=GETPOST("versionfrom",'alpha',3)?GETPOST("versionfrom",'alpha',3):(empty($argv[1])?'':$argv[1]); +$versionto=GETPOST("versionto",'alpha',3)?GETPOST("versionto",'alpha',3):(empty($argv[2])?'':$argv[2]); +$enablemodules=GETPOST("enablemodules",'alpha',3)?GETPOST("enablemodules",'alpha',3):(empty($argv[3])?'':$argv[3]); $langs->load('admin'); $langs->load('install'); @@ -416,6 +416,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 { // Reload modules (this must be always done and only into last targeted version) $listofmodules=array(); + $enablemodules=preg_replace('/enablemodules=/','',$enablemodules); $tmplistofmodules=explode(',', $enablemodules); foreach($tmplistofmodules as $value) { @@ -4279,6 +4280,16 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } + if ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; + if ($res) { + $mod=new modSupplierProposal($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod->init($reloadmode); + } + } if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); @@ -4309,6 +4320,16 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } + if ($moduletoreload == 'MAIN_MODULE_WEBSITE') // Module added in 7.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Website module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modWebsite.class.php'; + if ($res) { + $mod=new modWebsite($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } if (! empty($mod) && is_object($mod)) {