Skip to content

Commit

Permalink
Merge pull request #131 from Automattic/fix/125
Browse files Browse the repository at this point in the history
Check for superglobals before using them.
  • Loading branch information
donnchawp committed Feb 3, 2017
2 parents 4b908f2 + 3c5a22d commit 03c1af9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wp-cache-phase1.php
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

0 comments on commit 03c1af9

Please sign in to comment.