From 3d37783f4dc485aa14c47c842a6494d761d27b6c Mon Sep 17 00:00:00 2001 From: Nikolay Beketov Date: Sun, 3 Nov 2024 20:26:21 +0700 Subject: [PATCH] Fix get license info error Fix unknown error on getting license info on during system test --- src/Core/Workers/WorkerMarketplaceChecker.php | 9 +++++++-- .../Lib/License/GetLicenseInfoAction.php | 16 +++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Core/Workers/WorkerMarketplaceChecker.php b/src/Core/Workers/WorkerMarketplaceChecker.php index b5a0fa7c7..851470aea 100644 --- a/src/Core/Workers/WorkerMarketplaceChecker.php +++ b/src/Core/Workers/WorkerMarketplaceChecker.php @@ -76,8 +76,13 @@ public function start(array $argv): void $lastGetLicenseInfo = $managedCache->get(self::CACHE_KEY_LICENSE_INFO . ':' . $licenseKey); if ($lastGetLicenseInfo === null) { $regInfo = $lic->getLicenseInfo($licenseKey); - if ($regInfo instanceof SimpleXMLElement) { - file_put_contents(MarketPlaceProvider::LIC_FILE_PATH, json_encode($regInfo->attributes())); + if ($regInfo["success"]) { + if ($regInfo["result"] instanceof SimpleXMLElement) { + file_put_contents( + MarketPlaceProvider::LIC_FILE_PATH, + json_encode($regInfo["result"]->attributes()) + ); + } } } $managedCache->set(self::CACHE_KEY_LICENSE_INFO, time(), 86400 + $randomTTLShift); // Check every day diff --git a/src/PBXCoreREST/Lib/License/GetLicenseInfoAction.php b/src/PBXCoreREST/Lib/License/GetLicenseInfoAction.php index 3f6238095..c5c5dfa16 100644 --- a/src/PBXCoreREST/Lib/License/GetLicenseInfoAction.php +++ b/src/PBXCoreREST/Lib/License/GetLicenseInfoAction.php @@ -57,13 +57,19 @@ public static function main(): PBXApiResult if ($lastGetLicenseInfo === null) { $license = $di->get(MarketPlaceProvider::SERVICE_NAME); $licenseInfo = $license->getLicenseInfo($licenseKey); - if ($licenseInfo instanceof SimpleXMLElement) { - $res->success = true; - $res->data['licenseInfo'] = json_encode($licenseInfo); + if ($licenseInfo["success"]) { + if ($licenseInfo["result"] instanceof SimpleXMLElement) { + $res->success = true; + $res->data['licenseInfo'] = json_encode($licenseInfo["result"]); + } + // Check not often than every 2 minutes + $managedCache->set($cacheKey, $res->data['licenseInfo'], 120); + } else { + $res->success = false; + $res->messages[] = $licenseInfo["error"]; } - $managedCache->set($cacheKey, $res->data['licenseInfo'], 120); // Check not often than every 2 minutes } else { - $res->data['licenseInfo']=$lastGetLicenseInfo; + $res->data['licenseInfo'] = $lastGetLicenseInfo; $res->success = true; } } else {