From fbce5c4f7ca860bf49f43dc28e4510acf687245a Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Mon, 13 Jan 2025 16:44:06 +0000 Subject: [PATCH] Update legacy install step - Call AppInstallService - Update feedback handling --- .../Install/LegacyHandler/InstallHandler.php | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/core/backend/Install/LegacyHandler/InstallHandler.php b/core/backend/Install/LegacyHandler/InstallHandler.php index f98c6936c..f83d1e61c 100644 --- a/core/backend/Install/LegacyHandler/InstallHandler.php +++ b/core/backend/Install/LegacyHandler/InstallHandler.php @@ -136,7 +136,6 @@ class InstallHandler extends LegacyHandler */ public function installLegacy(): Feedback { - $this->switchSession($this->legacySessionName); chdir($this->legacyDir); $errorLevelStored = error_reporting(); @@ -155,48 +154,46 @@ class InstallHandler extends LegacyHandler $installResult = []; + if (!is_readable('include/portability/Install/AppInstallService.php')) { + $this->logger->error('An error occurred while installing SuiteCRM - not able to access portability/Install/AppInstallService.php'); + $feedback->setSuccess(false)->setMessages(['An error occurred while installing SuiteCRM - not able to access portability/Install/AppInstallService.php']); + chdir($this->projectDir); + + error_reporting($errorLevelStored); + + return $feedback; + } + try { ob_start(); ob_start(); /* @noinspection PhpIncludeInspection */ - include_once 'install_service.php'; + require_once 'include/portability/Install/AppInstallService.php'; + $appInstallService = new \AppInstallService(); + $installResult = $appInstallService->runInstall(); ob_end_clean(); ob_end_clean(); } catch (Throwable $t) { - $this->logger->error('An error occurred while installing SuiteCRM ' . $t->getMessage()); + $this->logger->error('An error occurred while installing SuiteCRM : ' . $t->getMessage()); + $installResult = $installResult ?? []; + $installResult['success'] = false; + $installResult['messages'] = $installResult['messages'] ?? []; + $installResult['messages'] = array_merge($installResult['messages'], ['Exception: ' . $t->getMessage()]); + } + + $success = ($installResult['success'] ?? false) && is_file('config.php'); + $installMessages = $installResult['messages'] ?? []; + + $messages = ['SuiteCRM Installation Completed']; + if (!$success) { $messages = ['An error occurred while installing SuiteCRM. Please check the logs.']; - if (!empty($installResult['messages'])) { - $messages = array_merge($messages, $installResult['messages']); - } - return $feedback->setSuccess(false)->setMessages($messages); } + $messages = array_merge($messages, $installMessages); - $success = false; - if (isset($installResult['success'])) { - $success = $installResult['success']; - } - - if ($success === true && is_file('config.php')) { - $messages = ['SuiteCRM Installation Completed']; - - if (!empty($installResult['messages'])) { - $messages = array_merge($messages, $installResult['messages']); - } - - $feedback->setSuccess(true)->setMessages($messages); - } else { - $messages = ['An error occurred while installing SuiteCRM. Please check the logs.']; - - if (!empty($installResult['messages'])) { - $messages = array_merge($messages, $installResult['messages']); - } - - $feedback->setSuccess(false)->setMessages($messages); - } + $feedback->setSuccess($success)->setMessages($messages); chdir($this->projectDir); - $this->switchSession($this->defaultSessionName); error_reporting($errorLevelStored);