mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-02 08:09:19 +08:00
Add file check for curl call
This commit is contained in:
parent
06dfae8792
commit
0bb9e5b211
3 changed files with 44 additions and 11 deletions
|
@ -33,6 +33,7 @@ use App\Engine\Model\Feedback;
|
|||
use App\Install\Service\Installation\InstallStatus;
|
||||
use App\Install\Service\InstallationUtilsTrait;
|
||||
use App\Install\Service\InstallPreChecks;
|
||||
use Exception;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use PDO;
|
||||
|
@ -213,27 +214,49 @@ class InstallHandler extends LegacyHandler
|
|||
$url = $inputArray['site_host'];
|
||||
|
||||
$log = new Logger('install.log');
|
||||
$log->pushHandler(new StreamHandler(__DIR__ . '/../../../../public/logs/install.log', Logger::DEBUG));
|
||||
$log->pushHandler(new StreamHandler(__DIR__ . '/../../../../logs/install.log', Logger::DEBUG));
|
||||
|
||||
$feedback = new Feedback();
|
||||
$feedback->setSuccess(true);
|
||||
|
||||
$checkFile = __DIR__ . '/../../../../.curl_check_main_page';
|
||||
|
||||
require_once "core/backend/Install/Service/InstallPreChecks.php";
|
||||
$installChecks = new InstallPreChecks($log);
|
||||
|
||||
try {
|
||||
file_put_contents($checkFile, 'running');
|
||||
} catch (Exception $e) {
|
||||
$feedback->setSuccess(false);
|
||||
$feedback->setErrors([$e->getMessage()]);
|
||||
return $feedback;
|
||||
}
|
||||
$results[] = $installChecks->checkMainPage($url);
|
||||
$results[] = $installChecks->checkGraphQlAPI($url);
|
||||
$modStrings = $installChecks->getLanguageStrings();
|
||||
|
||||
$feedback = new Feedback();
|
||||
$feedback->setSuccess(true);
|
||||
if (file_exists($checkFile)) {
|
||||
unlink($checkFile);
|
||||
}
|
||||
|
||||
$warnings = [];
|
||||
$errorsFound = false;
|
||||
|
||||
foreach ($results as $result) {
|
||||
if (is_array($result['errors'])) {
|
||||
foreach ($result['errors'] as $error) {
|
||||
if (in_array($error, $modStrings)) {
|
||||
|
||||
$errorsFound = true;
|
||||
|
||||
if (empty($error)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($error, $modStrings) && $error !== $modStrings['LBL_EMPTY']) {
|
||||
error_log(print_r($error, true));
|
||||
$warnings[] = "One or More Failed Checks: " . $error . " Please refer to the logs/install.log";
|
||||
}
|
||||
|
||||
$errorsFound = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -243,11 +266,11 @@ class InstallHandler extends LegacyHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ($errorsFound){
|
||||
if ($errorsFound) {
|
||||
$warnings[] = 'One or More Failed Checks: Please refer to the logs/install.log';
|
||||
}
|
||||
|
||||
if (isset($warnings)){
|
||||
if (isset($warnings)) {
|
||||
$feedback->setWarnings($warnings);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,23 +275,33 @@ class InstallPreChecks
|
|||
|
||||
$output = [];
|
||||
|
||||
$this->log->error($error);
|
||||
|
||||
file_put_contents($logFile, stream_get_contents($streamVerboseHandle), FILE_APPEND);
|
||||
rewind($streamVerboseHandle);
|
||||
$output['errors'][] = stream_get_contents($streamVerboseHandle);
|
||||
if (stream_get_contents($streamVerboseHandle) !== false && !empty(stream_get_contents($streamVerboseHandle))) {
|
||||
error_log(stream_get_contents($streamVerboseHandle));
|
||||
$this->log->error(stream_get_contents($streamVerboseHandle));
|
||||
error_log('inside if');
|
||||
$output['errors'][] = stream_get_contents($streamVerboseHandle);
|
||||
}
|
||||
fclose($streamVerboseHandle);
|
||||
$debug = ob_get_clean();
|
||||
$this->log->error($debug);
|
||||
$output['errors'][] = $error;
|
||||
$this->log->error($error);
|
||||
$output['errors'][] = 'The url used for the call was: ' . $baseUrl;
|
||||
$this->log->error('The url used for the call was: ' . $baseUrl);
|
||||
$output['errors'][] = 'The result of the call was: ';
|
||||
$this->log->error('The result of the call was: ');
|
||||
|
||||
if (!empty($result)) {
|
||||
$output['errors'][] = $result;
|
||||
$this->log->error($result);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output['errors'][] = $modStrings['LBL_EMPTY'];
|
||||
$this->log->error($modStrings['LBL_EMPTY']);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -317,7 +327,7 @@ class InstallPreChecks
|
|||
}
|
||||
$baseUrl = rtrim($baseUrl, '/');
|
||||
$baseUrl .= '/';
|
||||
$apiUrl = $baseUrl . '/api/graphql';
|
||||
$apiUrl = $baseUrl . 'api/graphql';
|
||||
$systemConfigApiQuery = '{"operationName":"systemConfigs","variables":{},"query":"query systemConfigs {\n systemConfigs {\n edges {\n node {\n id\n _id\n value\n items\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"}';
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $apiUrl);
|
||||
|
|
|
@ -23,7 +23,7 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false
|
|||
Request::setTrustedHosts([$trustedHosts]);
|
||||
}
|
||||
|
||||
if (!file_exists('legacy/config.php') && !file_exists('.installed_checked')){
|
||||
if (!file_exists('legacy/config.php') && !file_exists('../.installed_checked') && !file_exists('../.curl_check_main_page')){
|
||||
header('Location: install.php');
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue