Skip to content

Commit

Permalink
Fix get license info error
Browse files Browse the repository at this point in the history
Fix unknown error on getting license info on during system test
  • Loading branch information
jorikfon committed Nov 3, 2024
1 parent 878b75e commit 3d37783
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/Core/Workers/WorkerMarketplaceChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions src/PBXCoreREST/Lib/License/GetLicenseInfoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3d37783

Please sign in to comment.