From 688562a816dba37f312075195c901a0b32680a7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jul 2015 09:40:18 +0200 Subject: [PATCH] Fix regression: We can't yet set method __construct of DolibarrModules abstract because this break compatibility with a lot of external module and generate FATAL errors after migration. Because PHP is not yet able to manage try catch on FATAL error, we can't catch such error. Using bstract on constructor is so postponed. --- htdocs/core/lib/admin.lib.php | 12 ++++++------ htdocs/core/modules/DolibarrModules.class.php | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 05204885c9c..2eb0fbb77ba 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -837,13 +837,13 @@ function unActivateModule($value, $requiredby=1) } else { - // TODO Cannot instantiate abstract class - //$genericMod = new DolibarrModul($db); - //$genericMod->name=preg_replace('/^mod/i','',$modName); - //$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName)); - //$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName)); + // TODO Replace this afte DolibarrModules is moved as abstract class with a try catch to show module is bugged + $genericMod = new DolibarrModules($db); + $genericMod->name=preg_replace('/^mod/i','',$modName); + $genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName)); + $genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName)); dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName); - //$genericMod->_remove(); + $genericMod->_remove(); } // Desactivation des modules qui dependent de lui diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index eee8dd50287..e759bf9454a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -199,8 +199,11 @@ abstract class DolibarrModules * * @param DoliDB $db Database handler */ - abstract public function __construct($db); - + //public function __construct($db); + // We should but can't set this as abstract because this will make dolibarr hang + // after migration due to old module not implementing. We must wait PHP is able to make + // a try catch on Fatal error to manage this correctly. + /** * Enables a module. * Inserts all informations into database