From 32af681b7262630cfe7aadd357d53bf7ebf7ddef Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Mon, 13 Mar 2023 13:36:47 -0500 Subject: [PATCH] Pods Alt Cache 2.1.7 --- classes/Pods/Alternative/Cache/File.php | 24 +++++++++++++++++------- package.json | 2 +- pods-alternative-cache.php | 4 ++-- readme.txt | 6 +++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/classes/Pods/Alternative/Cache/File.php b/classes/Pods/Alternative/Cache/File.php index 9600266f..ae99107b 100644 --- a/classes/Pods/Alternative/Cache/File.php +++ b/classes/Pods/Alternative/Cache/File.php @@ -160,6 +160,11 @@ public function delete_files_in_directory( $directory = null ) { foreach ( $file_list as $file ) { $file_path = $directory . DIRECTORY_SEPARATOR . $file['name']; + // Check if this file still exists. + if ( ! $wp_filesystem->exists( $file_path ) ) { + continue; + } + // d = folder, f = file if ( 'd' === $file['type'] ) { // Delete folder. @@ -168,14 +173,19 @@ public function delete_files_in_directory( $directory = null ) { // Delete file. $wp_filesystem->delete( $file_path ); } + } - if ( PODS_ALT_FILE_CACHE_DIR !== $directory ) { - $wp_filesystem->rmdir( $directory ); - - pods_alternative_cache_log_message( 'Directory removed', __METHOD__, [ - '$directory' => $directory, - ] ); + if ( PODS_ALT_FILE_CACHE_DIR !== $directory ) { + // Check if this directory still exists. + if ( ! $wp_filesystem->exists( $directory ) ) { + return; } + + $wp_filesystem->rmdir( $directory ); + + pods_alternative_cache_log_message( 'Directory removed', __METHOD__, [ + '$directory' => $directory, + ] ); } } @@ -341,7 +351,7 @@ public function get_path_for_file( $file, $mkdir = false ) { foreach ( $directories as $directory ) { $dir_path .= DIRECTORY_SEPARATOR . $directory; - if ( $wp_filesystem->is_dir( $dir_path ) ) { + if ( $wp_filesystem->is_dir( $dir_path ) || $wp_filesystem->exists( $dir_path ) ) { continue; } diff --git a/package.json b/package.json index 4a861c57..940779a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pods-alternative-cache", - "version": "2.0.8", + "version": "2.1.7", "description": "Alternative caching engine for Pods for large sites on hosts with hard limits on how much you can store in the object cache.", "author": "Pods Foundation, Inc", "homepage": "https://pods.io", diff --git a/pods-alternative-cache.php b/pods-alternative-cache.php index cd4fe7b2..f6adcaa2 100644 --- a/pods-alternative-cache.php +++ b/pods-alternative-cache.php @@ -3,12 +3,12 @@ Plugin Name: Pods Alternative Cache Plugin URI: https://pods.io/2014/04/16/introducing-pods-alternative-cache/ Description: Alternative caching engine for Pods for large sites on hosts with hard limits on how much you can store in the object cache -Version: 2.1.6 +Version: 2.1.7 Author: Pods Framework Team Author URI: https://pods.io/ */ -define( 'PODS_ALT_CACHE_VERSION', '2.1.6' ); +define( 'PODS_ALT_CACHE_VERSION', '2.1.7' ); define( 'PODS_ALT_CACHE_DIR', plugin_dir_path( __FILE__ ) ); /** diff --git a/readme.txt b/readme.txt index 120d3e4c..9ada332c 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: pods, cache, wpengine Requires at least: 3.8 Tested up to: 6.2 Requires PHP: 5.6 -Stable tag: 2.1.6 +Stable tag: 2.1.7 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -76,6 +76,10 @@ Disable object cache fallback, when File writes fail: == Changelog == += 2.1.7 - March 13th, 2023 = + +* Fixed: Caught a bug hanging around for a few years that only happened in edge cases -- checking if file/directory still exists before trying to delete/remove it. (@sc0ttkclark) + = 2.1.6 - March 6th, 2023 = * Fixed: Prevent issue that sometimes happens with persistent object cache fallback when clearing cache for a group. (@sc0ttkclark)