From ae728562ac8c44153329e773d0b5cf105b2082a7 Mon Sep 17 00:00:00 2001 From: 8ctopus Date: Mon, 5 May 2025 09:52:22 +0400 Subject: [PATCH] Fix delete advanced cache when it is a symbolic link --- inc/cache_enabler_disk.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/inc/cache_enabler_disk.class.php b/inc/cache_enabler_disk.class.php index b9c4a78..051e562 100644 --- a/inc/cache_enabler_disk.class.php +++ b/inc/cache_enabler_disk.class.php @@ -52,7 +52,22 @@ public static function clean() { if ( ! is_dir( CACHE_ENABLER_SETTINGS_DIR ) ) { array_map( 'unlink', glob( WP_CONTENT_DIR . '/cache/cache-enabler-advcache-*.json' ) ); // < 1.4.0 array_map( 'unlink', glob( ABSPATH . 'CE_SETTINGS_PATH-*.json' ) ); // = 1.4.0 - @unlink( WP_CONTENT_DIR . '/advanced-cache.php' ); + + $file = WP_CONTENT_DIR . '/advanced-cache.php'; + + if ( ! is_link( $file )) { + @unlink( $file ); + } else { + $target = readlink( $file ); + + $cwd = getcwd(); + chdir( dirname( $file ) ); + + @unlink( realpath( $target ) ); + + chdir( $cwd ); + } + self::set_wp_cache_constant( false ); } }