Skip to content

Commit 14b9075

Browse files
diliritymatticbot
authored andcommitted
WP Super cache: make sure the debug log viewer isn't deleted by garbage collection (#38276)
* We always want a debug log viewer. Don't GC it. * changelog Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9872485011 Upstream-Ref: Automattic/jetpack@bf25dce
1 parent a677854 commit 14b9075

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ This is an alpha version! The changes listed here are not final.
1212
### Changed
1313
- Updated package dependencies.
1414

15+
### Fixed
16+
- WPSC: Don't delete the log viewer when doing garbage collection
17+
1518
## [1.12.2] - 2024-06-27
1619
### Added
1720
- add an admin notice to encourage migration to Jetpack Boost [#37933]

wp-cache-phase2.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ function wp_cache_rebuild_or_delete( $file ) {
27752775
}
27762776

27772777
function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
2778-
global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on;
2778+
global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on, $wp_cache_debug_log;
27792779

27802780
if ( $cache_max_time == 0 ) {
27812781
wp_cache_debug( 'wp_cache_phase2_clean_expired: disabled because GC disabled.', 2 );
@@ -2786,6 +2786,14 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
27862786
if ( ! wp_cache_writers_entry() ) {
27872787
return false;
27882788
}
2789+
2790+
// make sure we have a debug log viewer
2791+
if ( empty( $wp_cache_debug_log ) ) {
2792+
wpsc_create_debug_log();
2793+
} else {
2794+
touch( $cache_path . 'view_' . $wp_cache_debug_log ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_touch
2795+
}
2796+
27892797
$now = time();
27902798
wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
27912799
$deleted = 0;

0 commit comments

Comments
 (0)