Skip to content

Commit

Permalink
* Github merge:
Browse files Browse the repository at this point in the history
* Make sure $cache_path has a trailing slash (#77)
* Remove flush() (#127) but also check if headers are empty and flush and get headers again. (#179)
* Add fix for customizer (#161) and don't cache PUT AND DELETE requests (#178)
* Check for superglobals before using them. (#131)



git-svn-id: http://plugins.svn.wordpress.org/wp-super-cache/trunk@1588365 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
donncha committed Feb 3, 2017
1 parent 7d81737 commit da6ad95
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions wp-cache-phase1.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

do_cacheaction( 'cache_init' );

if ( ! $cache_enabled || in_array( $_SERVER["REQUEST_METHOD"], array( 'POST', 'PUT', 'DELETE' ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {

if ( ! $cache_enabled || ( isset( $_SERVER["REQUEST_METHOD"] ) && in_array( $_SERVER["REQUEST_METHOD"], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
return true;
}

Expand Down Expand Up @@ -100,9 +101,11 @@ function setup_blog_cache_dir() {

function get_wp_cache_key( $url = false ) {
global $wp_cache_request_uri, $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
if ( !$url )
if ( ! $url ) {
$url = $wp_cache_request_uri;
return do_cacheaction( 'wp_cache_key', $WPSC_HTTP_HOST . intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
}
$server_port = isset( $_SERVER[ 'SERVER_PORT' ] ) ? intval( $_SERVER[ 'SERVER_PORT' ] ) : 0;
return do_cacheaction( 'wp_cache_key', $WPSC_HTTP_HOST . $server_port . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
}

function wp_super_cache_init() {
Expand Down
5 changes: 4 additions & 1 deletion wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ function wp_cache_user_agent_is_rejected() {

function wp_cache_get_response_headers() {
if(function_exists('apache_response_headers')) {
flush();
$headers = apache_response_headers();
if ( empty( $headers ) ) {
flush();
$headers = apache_response_headers();
}
} else if(function_exists('headers_list')) {
$headers = array();
foreach(headers_list() as $hdr) {
Expand Down
5 changes: 3 additions & 2 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,13 @@ function wp_cache_manager_updates() {
}

if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) {
if( isset( $_POST[ 'wp_cache_location' ] ) && $_POST[ 'wp_cache_location' ] != '' ) {
if( isset( $_POST[ 'wp_cache_location' ] ) && $_POST[ 'wp_cache_location' ] != '' &&
( !isset( $cache_path ) || $_POST[ 'wp_cache_location' ] != $cache_path ) ) {
$dir = realpath( trailingslashit( dirname( $_POST[ 'wp_cache_location' ] ) ) );
if ( $dir == false )
$dir = WP_CONTENT_DIR . '/cache/';
else
$dir = trailingslashit( $dir ) . wpsc_deep_replace( array( '..', '\\' ), basename( $_POST[ 'wp_cache_location' ] ) );
$dir = trailingslashit( $dir ) . trailingslashit(wpsc_deep_replace( array( '..', '\\' ), basename( $_POST[ 'wp_cache_location' ] ) ) );
$new_cache_path = $dir;
} else {
$new_cache_path = WP_CONTENT_DIR . '/cache/';
Expand Down

0 comments on commit da6ad95

Please sign in to comment.