EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Ugprade unknown version handling
Yurii2720b492b186
diff --git a/application/Espo/Core/Console/Commands/Upgrade.php b/application/Espo/Core/Console/Commands/Upgrade.phpindex 048c059fa0..317e46678b 100644--- a/application/Espo/Core/Console/Commands/Upgrade.php+++ b/application/Espo/Core/Console/Commands/Upgrade.php@@ -46,6 +46,7 @@ use Exception;use Throwable;use stdClass;+use UnexpectedValueException;use const CURLOPT_FILE;use const CURLOPT_RETURNTRANSFER;use const CURLOPT_SSL_VERIFYPEER;@@ -108,7 +109,13 @@ class Upgrade implements Command$fromVersion = $this->config->get('version');$toVersion = $upgradeParams->toVersion ?? null;- $versionInfo = $this->getVersionInfo($toVersion);+ try {+ $versionInfo = $this->getVersionInfo($toVersion);+ } catch (UnexpectedValueException) {+ fwrite(STDOUT, "Current '$fromVersion' version is unknown.\n");++ return;+ }$nextVersion = $versionInfo->nextVersion ?? null;$lastVersion = $versionInfo->lastVersion ?? null;@@ -444,6 +451,16 @@ class Upgrade implements Command$result = curl_exec($ch);+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);++ if ($httpCode === 422) {+ throw new UnexpectedValueException();+ }++ if ($result === false) {+ return null;+ }+try {$data = json_decode($result); /** @phpstan-ignore-line */} catch (Exception) { /** @phpstan-ignore-line */