← All changes
|
minify/class-wp-optimize-minify-cache-functions.php
+15
-2
4.6.1
→
4.7.0
View file →
| @@ -353,10 +353,13 @@ | ||
| 353 | 353 | continue; |
| 354 | 354 | } |
| 355 | 355 | $log[] = "cache expiration time - $expires"; |
| 356 | 356 | $log[] = "checking if cache has expired - $d"; |
| 357 | - if ($d !== $cache_time && (is_numeric($d) && $d <= $expires)) { | |
| 358 | - $dir = WPO_CACHE_MIN_FILES_DIR.'/'.$d; | |
| 357 | + | |
| 358 | + $dir = WPO_CACHE_MIN_FILES_DIR.'/'.$d; | |
| 359 | + $is_empty_dir = self::is_empty_minify_subdir($dir); | |
| 360 | + | |
| 361 | + if ($d !== (string) $cache_time && (is_numeric($d) && $d <= $expires || $is_empty_dir)) { | |
| 359 | 362 | if (is_dir($dir)) { |
| 360 | 363 | $log[] = "deleting cache in $dir"; |
| 361 | 364 | if (wpo_delete_files($dir)) { |
| 362 | 365 | $log[] = "files and folders are deleted recursively - $dir"; |
| @@ -382,8 +385,18 @@ | ||
| 382 | 385 | } |
| 383 | 386 | } |
| 384 | 387 | |
| 385 | 388 | return $log; |
| 389 | + } | |
| 390 | + | |
| 391 | + /** | |
| 392 | + * Checks whether the minify cache subdirectory (/ddddddddd/) is empty, i.e. whether the 'assets' and 'header' subdirectories contain no files. | |
| 393 | + * | |
| 394 | + * @param string $dir | |
| 395 | + * @return boolean | |
| 396 | + */ | |
| 397 | + private static function is_empty_minify_subdir($dir) { | |
| 398 | + return wpo_is_empty_dir($dir . '/assets') && wpo_is_empty_dir($dir . '/header'); | |
| 386 | 399 | } |
| 387 | 400 | |
| 388 | 401 | /** |
| 389 | 402 | * Get transients from the disk |