From a2794c70fc7cf03de0d2bf6dd0b9dd0d20d4b848 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 8 Sep 2014 18:24:12 +0200 Subject: [PATCH] Write disk cache atomically --- .../lib/system/cache/source/DiskCacheSource.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php b/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php index 639d8ad43e..d37cd417e9 100644 --- a/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php @@ -1,7 +1,7 @@ getFilename($cacheName)); - $file->write("\n"); - $file->write(serialize($value)); - $file->close(); + $writer = new AtomicWriter($this->getFilename($cacheName)); + $writer->write("\n"); + $writer->write(serialize($value)); + $writer->flush(); + $writer->close(); // unset current DirectoryUtil object to make sure new cache file // can be deleted in the same request -- 2.20.1