From 4549a9297e81ac18a90004983ff1d08a5f54b0cb Mon Sep 17 00:00:00 2001 From: Konstantin Kovshenin Date: Tue, 19 Apr 2022 11:27:12 +0300 Subject: [PATCH] Invalidate: Make sure CACHE_DIR exists before writing flags --- include/invalidate.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/invalidate.php b/include/invalidate.php index 11dd947..f1f153a 100644 --- a/include/invalidate.php +++ b/include/invalidate.php @@ -134,7 +134,14 @@ $flags = null; $path = CACHE_DIR . '/flags.json.php'; - $mode = file_exists( $path ) ? 'r+' : 'w+'; + $exists = file_exists( $path ); + $mode = $exists ? 'r+' : 'w+'; + + // Make sure cache dir exists. + if ( ! $exists && ! wp_mkdir_p( CACHE_DIR ) ) { + return; + } + $f = fopen( $path, $mode ); $length = filesize( $path );