Skip to content

Commit ea83e75

Browse files
committed
WP Super Cache: Fix fatal error when getmypid() is unavailable in debug logging
Add function_exists check before calling getmypid() to prevent fatal errors in environments where the function is disabled (e.g., via disable_functions in php.ini by hosting providers).
1 parent f89f528 commit ea83e75

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
WP Super Cache: Fix fatal error when getmypid() is unavailable in debug logging

projects/plugins/super-cache/wp-cache-phase2.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,11 @@ function wp_cache_debug( $message, $level = 1 ) {
754754
}
755755

756756
// Log message: Date URI Message
757-
$log_message = date( 'H:i:s' ) . ' ' . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL;
757+
if ( function_exists( 'getmypid' ) ) {
758+
$log_message = date( 'H:i:s' ) . ' ' . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL;
759+
} else {
760+
$log_message = date( 'H:i:s' ) . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL;
761+
}
758762
// path to the log file in the cache folder
759763
$log_file = $cache_path . str_replace( '/', '', str_replace( '..', '', $wp_cache_debug_log ) );
760764

0 commit comments

Comments
 (0)