Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,16 @@ function wp_cache_debug_settings() {
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
}
$log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}view_{$wp_cache_debug_log}" ) ) . "'>$wp_cache_debug_log</a>";
$raw_log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}{$wp_cache_debug_log}" ) ) . "'>" . __( 'RAW', 'wp-super-cache' ) . "</a>";
if ( function_exists( 'wp_normalize_path' ) ) {
$cache_url = wp_normalize_path( $cache_path );
$cache_url = str_replace( wp_normalize_path( ABSPATH ), '', $cache_url );
} else {
$cache_url = str_replace( '\\', '/', $cache_path );
$cache_url = str_replace( str_replace( '\\', '/', ABSPATH ), '', $cache_url );
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found old laptop with Windows XP/PHP 5.2,5.3,5.4. I've tested following code:

Suggested change
}
// Extracts and normalizes relative path.
$cache_rel_path = str_replace( realpath( ABSPATH ), '', realpath( $cache_path ) );
$cache_rel_path = str_replace( '\\', '/', $cache_rel_path );

It seems OK by first tests and it's more readable. We need only to replace \ because $cache_rel_path doesn't contain drive letter.

$cache_url = site_url( $cache_url );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$cache_url = site_url( $cache_url );
$cache_url = trailingslashit( site_url( $cache_rel_path ) );

It's possible to realpath strips last slash.

$log_file_link = "<a href='{$cache_url}view_{$wp_cache_debug_log}'>$wp_cache_debug_log</a>";
$raw_log_file_link = "<a href='{$cache_url}{$wp_cache_debug_log}'>" . __( 'RAW', 'wp-super-cache' ) . "</a>";
if ( $wp_super_cache_debug == 1 ) {
echo "<p>" . sprintf( __( 'Currently logging to: %s (%s)', 'wp-super-cache' ), $log_file_link, $raw_log_file_link ) . "</p>";
} else {
Expand Down