Clear the license data by writing `null` to the license file
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:32:14 +0000 (15:32 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:40:56 +0000 (15:40 +0200)
This will allow to save the readability check in a follow-up commit.

wcfsetup/install/files/lib/acp/form/LicenseEditForm.class.php
wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php

index 252910d64ba5b386b977749baf4168b1dde4f9c0..5a1d93ee3c36f9687c7c23f4889fcc6c38877049 100644 (file)
@@ -211,7 +211,7 @@ final class LicenseEditForm extends AbstractFormBuilderForm
 
             $authCode = $this->licenseData->license['authCode'] ?? '';
         } else {
-            $this->licenseApi->removeLicenseFile();
+            $this->licenseApi->clearLicenseFile();
         }
 
         $objectAction = new OptionAction(
index c51a028307bd37fe236d501850000c9065a8a4cb..8bd70517d28c81e89c05f9929d9f939b37cebd1e 100644 (file)
@@ -23,7 +23,7 @@ final class LicenseApi
 {
     private const LICENSE_FILE = \WCF_DIR . 'license.php';
 
-    public function updateLicenseFile(LicenseData $data): void
+    public function updateLicenseFile(?LicenseData $data): void
     {
         @\file_put_contents(
             self::LICENSE_FILE,
@@ -91,13 +91,9 @@ final class LicenseApi
         return require(self::LICENSE_FILE);
     }
 
-    public function removeLicenseFile(): void
+    public function clearLicenseFile(): void
     {
-        if (!\file_exists(self::LICENSE_FILE)) {
-            return;
-        }
-
-        \unlink(self::LICENSE_FILE);
+        $this->updateLicenseFile(null);
     }
 
     public static function hasLicenseCredentials(): bool