Fix InstallHandler

This commit is contained in:
Clemente Raposo 2025-01-10 15:05:46 +00:00 committed by c.raposo
parent 759c4c0011
commit 308e254644

View file

@ -43,6 +43,7 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Throwable;
/** /**
* Class InstallHandler * Class InstallHandler
@ -152,17 +153,46 @@ class InstallHandler extends LegacyHandler
$_REQUEST['goto'] = 'SilentInstall'; $_REQUEST['goto'] = 'SilentInstall';
$_REQUEST['cli'] = 'true'; $_REQUEST['cli'] = 'true';
ob_start(); $installResult = [];
ob_start();
/* @noinspection PhpIncludeInspection */
include_once 'install.php';
ob_end_clean();
ob_end_clean();
if (is_file('config.php')) { try {
$feedback->setSuccess(true)->setMessages(['SuiteCRM Installation Completed']); 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 { } 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); chdir($this->projectDir);