From 308e254644eccbcaf4d81c38661e6108f8c022b7 Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Fri, 10 Jan 2025 15:05:46 +0000 Subject: [PATCH] Fix InstallHandler --- .../Install/LegacyHandler/InstallHandler.php | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/core/backend/Install/LegacyHandler/InstallHandler.php b/core/backend/Install/LegacyHandler/InstallHandler.php index 586a8e596..f98c6936c 100644 --- a/core/backend/Install/LegacyHandler/InstallHandler.php +++ b/core/backend/Install/LegacyHandler/InstallHandler.php @@ -43,6 +43,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\RequestStack; +use Throwable; /** * Class InstallHandler @@ -152,17 +153,46 @@ class InstallHandler extends LegacyHandler $_REQUEST['goto'] = 'SilentInstall'; $_REQUEST['cli'] = 'true'; - ob_start(); - ob_start(); - /* @noinspection PhpIncludeInspection */ - include_once 'install.php'; - ob_end_clean(); - ob_end_clean(); + $installResult = []; - if (is_file('config.php')) { - $feedback->setSuccess(true)->setMessages(['SuiteCRM Installation Completed']); + try { + ob_start(); + ob_start(); + /* @noinspection PhpIncludeInspection */ + include_once 'install_service.php'; + ob_end_clean(); + ob_end_clean(); + } catch (Throwable $t) { + $this->logger->error('An error occurred while installing SuiteCRM ' . $t->getMessage()); + + $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); + } + + $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 { - $feedback->setSuccess(false)->setMessages(['SuiteCRM Installation Failed']); + $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); } chdir($this->projectDir);