From c70293edf201fb2bcb89880cba16ff6159f99445 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 6 Aug 2022 13:49:31 +0900 Subject: [PATCH] Only install and update default modules #1967 --- modules/install/install.controller.php | 60 +++++++++++++++++--------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 923b39a1b..b39d3f033 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -458,7 +458,6 @@ class installController extends install */ function installDownloadedModule() { - $oModuleModel = getModel('module'); // Create a table ny finding schemas/*.xml file in each module $module_list = FileHandler::readDir('./modules/', NULL, false, true); $modules = array(); @@ -466,19 +465,29 @@ class installController extends install { // Get module name $module = basename($module_path); - $xml_info = $oModuleModel->getModuleInfoXml($module); - if(!$xml_info) continue; - $modules[$xml_info->category][] = $module; + + // Only install default modules at this time + if (!Context::isDefaultPlugin($module, 'module')) + { + continue; + } + + // Try to group modules by category + $xml_info = ModuleModel::getModuleInfoXml($module); + if (!$xml_info) + { + continue; + } + $modules[$xml_info->category ?: 'other'][] = $module; } + // Install "module" module in advance $this->installModule('module','./modules/module'); - $oModule = ModuleModel::getModuleInstallClass($module); - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate') && $oModule->checkUpdate()) - { - $oModule->moduleUpdate(); - } + $this->updateModule('module'); + // Determine the order of module installation depending on category $install_step = array('system','content','member'); + // Install all the remaining modules foreach($install_step as $category) { @@ -488,16 +497,12 @@ class installController extends install { if($module == 'module') continue; $this->installModule($module, sprintf('./modules/%s', $module)); - - $oModule = ModuleModel::getModuleInstallClass($module); - if(is_object($oModule) && method_exists($oModule, 'checkUpdate')) - { - if($oModule->checkUpdate()) $oModule->moduleUpdate(); - } + $this->updateModule($module); } unset($modules[$category]); } } + // Install all the remaining modules if(count($modules)) { @@ -509,12 +514,7 @@ class installController extends install { if($module == 'module') continue; $this->installModule($module, sprintf('./modules/%s', $module)); - - $oModule = ModuleModel::getModuleInstallClass($module); - if($oModule && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) - { - if($oModule->checkUpdate()) $oModule->moduleUpdate(); - } + $this->updateModule($module); } } } @@ -573,6 +573,24 @@ class installController extends install return new BaseObject(); } + /** + * Update a module if necessary. + * + * @param string $module + * @return mixed + */ + public function updateModule($module) + { + $oModule = ModuleModel::getModuleInstallClass($module); + if (is_object($oModule) && method_exists($oModule, 'checkUpdate') && method_exists($oModule, 'moduleUpdate')) + { + if ($oModule->checkUpdate()) + { + return $oModule->moduleUpdate(); + } + } + } + /** * Placeholder for third-party apps that try to manipulate system configuration. *