Write an empty license file when failing to read the license data
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:34:00 +0000 (15:34 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:40:57 +0000 (15:40 +0200)
wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php
wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php

index 1f586251faf906ef9d2b9ebe1b23174010b44238..b5bca3d12d1f9cf06c89bc644bba51adf7fdf923 100644 (file)
@@ -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;
index 0109b60f4c3b1f91cd72912725afa6baeec2015c..6ab5cb3a009bf6b3cfa00b5c58d32ecbe29b6a9c 100644 (file)
@@ -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 '';
         }
index 8bd70517d28c81e89c05f9929d9f939b37cebd1e..7d6f024d2feb84c25a6e802d8d366e3320374c71 100644 (file)
@@ -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