From f0336ef097f5fb9823c31dd40167d2dd5bfa5088 Mon Sep 17 00:00:00 2001 From: Paul Ellmaier Date: Fri, 3 Feb 2017 13:52:49 +0100 Subject: [PATCH 1/2] better hdd cache invalidation --- inc/cachify_hdd.class.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/inc/cachify_hdd.class.php b/inc/cachify_hdd.class.php index 46ba8102..7b2939f1 100644 --- a/inc/cachify_hdd.class.php +++ b/inc/cachify_hdd.class.php @@ -117,7 +117,8 @@ public static function delete_item($hash = '', $url) public static function clear_cache() { self::_clear_dir( - CACHIFY_CACHE_DIR + CACHIFY_CACHE_DIR, + true ); } @@ -227,15 +228,16 @@ private static function _create_file($file, $data) /** - * Clear directory recursively + * Clear directory * * @since 2.0 * @change 2.0.5 * - * @param string $dir Directory path + * @param string $dir Directory path + * @param boolean $recursive clear subdirectories */ - private static function _clear_dir($dir) { + private static function _clear_dir($dir, $recursive = false) { /* Remote training slash */ $dir = untrailingslashit($dir); @@ -261,15 +263,17 @@ private static function _clear_dir($dir) { $object = $dir. DIRECTORY_SEPARATOR .$object; /* Directory or file */ - if ( is_dir($object) ) { - self::_clear_dir($object); + if ( is_dir($object) && $recursive ) { + self::_clear_dir($object, $recursive); } else { unlink($object); } } /* Remove directory */ - @rmdir($dir); + if( $recursive ) { + @rmdir($dir); + } /* CleanUp */ clearstatcache(); From da1a3b0baa54b2d50c529c549a9bb72faedd7656 Mon Sep 17 00:00:00 2001 From: Paul Ellmaier Date: Tue, 21 Feb 2017 09:24:47 +0100 Subject: [PATCH 2/2] fix formatting according to wp codex --- inc/cachify_hdd.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/cachify_hdd.class.php b/inc/cachify_hdd.class.php index 7b2939f1..bd763c8e 100644 --- a/inc/cachify_hdd.class.php +++ b/inc/cachify_hdd.class.php @@ -271,7 +271,7 @@ private static function _clear_dir($dir, $recursive = false) { } /* Remove directory */ - if( $recursive ) { + if ( $recursive ) { @rmdir($dir); }