From: Tim Düsterhus Date: Wed, 27 Sep 2023 13:34:00 +0000 (+0200) Subject: Write an empty license file when failing to read the license data X-Git-Tag: 6.0.0_RC_2~3^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=895acf5e06b885805ebc552ff5fa0a0dd03f8c1e;p=GitHub%2FWoltLab%2FWCF.git Write an empty license file when failing to read the license data --- diff --git a/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php b/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php index 1f586251fa..b5bca3d12d 100644 --- a/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php +++ b/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php @@ -65,7 +65,8 @@ return static function (): void { }); try { - $licenseData = LicenseApi::readFromFile(); + $licenseApi = new LicenseApi(); + $licenseData = $licenseApi->readFromFile(); if ($licenseData !== null) { $brandingFree = $licenseData->woltlab['com.woltlab.brandingFree'] ?? '0.0'; $expiresAt = $licenseData->license['expiryDates']['com.woltlab.brandingFree'] ?? \TIME_NOW; diff --git a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php index 0109b60f4c..6ab5cb3a00 100644 --- a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php @@ -328,7 +328,9 @@ class BBCodeHandler extends SingletonFactory */ public function getCkeditorLicenseKey(): string { - $licenseData = LicenseApi::readFromFile(); + $licenseApi = new LicenseApi(); + $licenseData = $licenseApi->readFromFile(); + if ($licenseData === null) { return ''; } diff --git a/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php b/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php index 8bd70517d2..7d6f024d2f 100644 --- a/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php +++ b/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php @@ -82,13 +82,15 @@ final class LicenseApi return self::parseLicenseData($response->getBody()); } - public static function readFromFile(): ?LicenseData + public function readFromFile(): ?LicenseData { - if (!\is_readable(self::LICENSE_FILE)) { + try { + return require(self::LICENSE_FILE); + } catch (\Throwable) { + $this->clearLicenseFile(); + return null; } - - return require(self::LICENSE_FILE); } public function clearLicenseFile(): void