From bbf7e82d09c74d01107a1b76ae11a786080f0f21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 29 Sep 2023 11:21:03 +0200 Subject: [PATCH] Use AtomicWriter to write the updated license file The license file is rewritten automatically when refreshing the package list. Depending on the timing it might only be partially written in case of concurrent requests. --- .../system/package/license/LicenseApi.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 5823bd620c..e0151f559f 100644 --- a/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php +++ b/wcfsetup/install/files/lib/system/package/license/LicenseApi.class.php @@ -8,6 +8,7 @@ use CuyZ\Valinor\Mapper\Source\Source; use CuyZ\Valinor\MapperBuilder; use GuzzleHttp\Psr7\Request; use wcf\data\package\update\server\PackageUpdateServer; +use wcf\system\io\AtomicWriter; use wcf\system\io\HttpFactory; use wcf\system\package\license\exception\MissingCredentials; use wcf\system\package\license\exception\ParsingFailed; @@ -27,18 +28,17 @@ final class LicenseApi public function updateLicenseFile(?LicenseData $data): void { - @\file_put_contents( - self::LICENSE_FILE, - \sprintf( - <<<'EOT' + $writer = new AtomicWriter(self::LICENSE_FILE); + $writer->write(\sprintf( + <<<'EOT' flush(); WCF::resetZendOpcache(self::LICENSE_FILE); } -- 2.20.1