From b807b864924ae2bcc30ec53162a42126455ae4ab Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Mon, 30 Sep 2024 09:50:13 +0200 Subject: [PATCH] Displays an error message if the license information couldn't be fetched. --- .../ExpiringLicensesAcpDashboardBox.class.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/acp/dashboard/box/ExpiringLicensesAcpDashboardBox.class.php b/wcfsetup/install/files/lib/system/acp/dashboard/box/ExpiringLicensesAcpDashboardBox.class.php index 0f69f5c7e7d..c5b63cf39bc 100644 --- a/wcfsetup/install/files/lib/system/acp/dashboard/box/ExpiringLicensesAcpDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/acp/dashboard/box/ExpiringLicensesAcpDashboardBox.class.php @@ -19,6 +19,7 @@ final class ExpiringLicensesAcpDashboardBox extends AbstractAcpDashboardBox { private ?LicenseData $licenseData; private array $expiredLicenses; + private bool $fetchLicenseDataFailed = false; #[\Override] public function isAccessible(): bool @@ -29,7 +30,7 @@ public function isAccessible(): bool #[\Override] public function hasContent(): bool { - return $this->getExpiredLicenses() !== []; + return $this->getExpiredLicenses() !== [] || $this->fetchLicenseDataFailed; } private function getExpiredLicenses(): array @@ -61,7 +62,13 @@ private function getLicenseData(): ?LicenseData { if (!isset($this->licenseData)) { $licenseApi = new LicenseApi(); - $this->licenseData = $licenseApi->getUpToDateLicenseData(); + + try { + $this->licenseData = $licenseApi->getUpToDateLicenseData(); + } catch (\Throwable) { + $this->licenseData = null; + $this->fetchLicenseDataFailed = true; + } } return $this->licenseData; @@ -76,6 +83,15 @@ public function getTitle(): string #[\Override] public function getContent(): string { + if ($this->fetchLicenseDataFailed) { + return \sprintf( + '%s', + WCF::getLanguage()->getDynamicVariable('wcf.acp.license.error.parsingFailed', [ + 'licenseData' => null, + ]) + ); + } + $packages = []; foreach (\array_keys($this->getExpiredLicenses()) as $packageName) { $packages[$packageName] = PackageCache::getInstance()->getPackageByIdentifier($packageName);