From: Tim Düsterhus Date: Fri, 29 Sep 2023 09:21:03 +0000 (+0200) Subject: Use AtomicWriter to write the updated license file X-Git-Tag: 6.0.0~37 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bbf7e82d09c74d01107a1b76ae11a786080f0f21;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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); }