Skip to content

Commit

Permalink
Rename the temp config file correctly and remove wp-admin/.php files (#…
Browse files Browse the repository at this point in the history
…673)

The rename created a file called ".php" in wp-admin before writing to
the configuration file. The file is empty but this patch adds a fixer
function to delete it and also fixes the rename.

Reported:
https://wordpress.org/support/topic/php-notice-undefined-variable-13/
https://wordpress.org/support/topic/wp-super-cache-created-a-stray-php/
  • Loading branch information
donnchawp authored May 26, 2019
1 parent 8cf4d4a commit fdc9e91
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
}

$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
rename( $tmp_config_filename, $tmp_wpcache_filename . ".php" );
rename( $tmp_config_filename, $tmp_config_filename. ".php" );
$tmp_config_filename .= ".php";
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
$fd = fopen( $tmp_config_filename, 'w' );
Expand Down
26 changes: 26 additions & 0 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ function wp_super_cache_init_action() {

wpsc_register_post_hooks();

if ( is_admin() ) {
wpsc_fix_164();
}
}
add_action( 'init', 'wp_super_cache_init_action' );

Expand Down Expand Up @@ -4283,3 +4286,26 @@ function wpsc_get_extra_cookies() {
return '';
}
}

/*
* 1.6.4 created an empty file called wp-admin/.php that must be cleaned up.
*/
function wpsc_fix_164() {
global $wpsc_fix_164;

if (
isset( $wpsc_fix_164 ) &&
$wpsc_fix_164
) {
return false;
}

if (
file_exists( ABSPATH . '/wp-admin/.php' ) &&
0 == filesize( ABSPATH . '/wp-admin/.php' )
) {
@unlink( ABSPATH . '/wp-admin/.php' );
}

wp_cache_setting( 'wpsc_fix_164', 1 );
}

0 comments on commit fdc9e91

Please sign in to comment.