From a537c1add54f06c658e6396c1ac3fae3ec1144b2 Mon Sep 17 00:00:00 2001 From: Krystian Szymukowicz Date: Sat, 21 Sep 2024 14:46:35 +0200 Subject: [PATCH] [BUGFIX] Fix problem of concurrent API calls in development mode break due to meta-data writing/loading is not "thread safe" (#103) --- Classes/Service/SerializerMetadataService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Service/SerializerMetadataService.php b/Classes/Service/SerializerMetadataService.php index 0d76565..4db92cc 100644 --- a/Classes/Service/SerializerMetadataService.php +++ b/Classes/Service/SerializerMetadataService.php @@ -46,10 +46,12 @@ public static function generateAutoloadForClass(string $class): void self::getMetadataFromMetadataDirs($reflectionClass->getName()) ); + $tmpFile = $generatedMetadataFile . '.' . uniqid('', true); file_put_contents( - $generatedMetadataFile, + $tmpFile, Yaml::dump([$reflectionClass->getName() => $classMergedMetadata], 99) ); + rename($tmpFile, $generatedMetadataFile); self::$runtimeGeneratedCache[] = $reflectionClass->getName(); }